Changes in / [262a864:80018f5]


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cpp

    r262a864 r80018f5  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 20:50:27 2024
    13 // Update Count     : 1110
     12// Last Modified On : Thu Sep 12 22:40:35 2024
     13// Update Count     : 1090
    1414//
    1515
     
    162162                lnthSuffix( str, type, ltype );                                 // could have length suffix
    163163        } else {
    164                 // At least one digit in integer constant, so safe to backup while looking for suffix.  This
    165                 // declaration and the comma expressions in the conditions mimic the declare and check
    166                 // pattern allowed in later compiler versions.  (Only some early compilers/C++ standards do
    167                 // not support it.)
     164                // At least one digit in integer constant, so safe to backup while looking for suffix.
     165                // This declaration and the comma expressions in the conditions mimic
     166                // the declare and check pattern allowed in later compiler versions.
     167                // (Only some early compilers/C++ standards do not support it.)
    168168                string::size_type posn;
    169169                // pointer value
     
    465465}
    466466
    467 // A "sequence" is the series of characters in a character/string literal that becomes a single
    468 // character value in the runtime value.
     467// A "sequence" is the series of characters in a character/string literal
     468// that becomes a single character value in the runtime value.
    469469static size_t sequenceLength( const std::string & str, size_t pos ) {
    470470        // Most "sequences" are just a single character, filter those out:
     
    497497                assertf( false, "Unknown escape sequence (start %c).", str[pos] );
    498498                return 1;
    499         } // switch
     499        }
    500500}
    501501
    502 ast::Expr * build_constantStr( const CodeLocation & location, string & str ) {
     502ast::Expr * build_constantStr(
     503                const CodeLocation & location,
     504                string & str ) {
    503505        assert( str.length() > 0 );
    504506        string units;                                                                           // units
     
    523525        } // switch
    524526
    525         // The length value of the type is equal to the number of "sequences" not including the openning
    526         // and closing quotes in the literal plus 1 for the implicit null terminator.
    527         size_t length = 1;
    528         for ( size_t pos = 1 ; pos < str.size() - 1 ; pos += sequenceLength( str, pos ) ) {
    529                 if ( '"' == str[pos] ) {                                                // concatenated strings ? "ABC" "DEF"
    530                         int cnt = 1;                                                            // skip outside quotes and space between
    531                         for ( unsigned int i = pos + 1; str[i] != '"'; i += 1, cnt += 1 );
    532                         pos += cnt;
    533                         continue;                                                                       // not part of length
    534                 } // if
    535                 length += 1;
    536         } // for
     527        // The dimension value of the type is equal to the number of "sequences"
     528        // not including the openning and closing quotes in the literal plus 1
     529        // for the implicit null terminator.
     530        size_t dimension = 1;
     531        for ( size_t pos = 1 ; pos < str.size() - 1 ;
     532                        pos += sequenceLength( str, pos ) ) {
     533                dimension += 1;
     534        }
    537535
    538536        ast::ArrayType * at = new ast::ArrayType(
    539537                strtype,
    540                 ast::ConstantExpr::from_ulong( location, length ),
     538                ast::ConstantExpr::from_ulong( location, dimension ),
    541539                ast::FixedLen,
    542540                ast::DynamicDim );
    543541        ast::Expr * ret = new ast::ConstantExpr( location, at, str, std::nullopt );
    544542        if ( units.length() != 0 ) {
    545                 ret = new ast::UntypedExpr( location, new ast::NameExpr( location, units ),     { ret } );
     543                ret = new ast::UntypedExpr( location,
     544                        new ast::NameExpr( location, units ),
     545                        { ret } );
    546546        } // if
    547547
  • tests/.expect/attributes.x64.txt

    r262a864 r80018f5  
    13391339__attribute__ (( noreturn )) void _X4fredFv___1(void){
    13401340    __attribute__ ((unused)) signed int _X1ii_2;
    1341     __attribute__ ((gnu::xxx)) signed int _X1ji_2;
    13421341    switch ( 3 ) {
    13431342        case 2:
  • tests/attributes.cfa

    r262a864 r80018f5  
    1010// Created On       : Mon Feb  6 16:07:02 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 14:45:04 2024
    13 // Update Count     : 51
     12// Last Modified On : Sun Dec 15 17:45:39 2024
     13// Update Count     : 49
    1414//
    1515
     
    164164[[ noreturn ]] void fred() {
    165165        int [[unused]] i;
    166         int [[gnu::xxx]] j;
    167166        switch ( 3 ) {
    168167          case 2:
Note: See TracChangeset for help on using the changeset viewer.