Changes in / [262a864:80018f5]
- Files:
-
- 3 edited
-
src/Parser/ExpressionNode.cpp (modified) (5 diffs)
-
tests/.expect/attributes.x64.txt (modified) (1 diff)
-
tests/attributes.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cpp
r262a864 r80018f5 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 20:50:27202413 // Update Count : 1 11012 // Last Modified On : Thu Sep 12 22:40:35 2024 13 // Update Count : 1090 14 14 // 15 15 … … 162 162 lnthSuffix( str, type, ltype ); // could have length suffix 163 163 } else { 164 // At least one digit in integer constant, so safe to backup while looking for suffix. This165 // declaration and the comma expressions in the conditions mimic the declare and check166 // pattern allowed in later compiler versions. (Only some early compilers/C++ standards do167 // 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.) 168 168 string::size_type posn; 169 169 // pointer value … … 465 465 } 466 466 467 // A "sequence" is the series of characters in a character/string literal that becomes a single468 // 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. 469 469 static size_t sequenceLength( const std::string & str, size_t pos ) { 470 470 // Most "sequences" are just a single character, filter those out: … … 497 497 assertf( false, "Unknown escape sequence (start %c).", str[pos] ); 498 498 return 1; 499 } // switch499 } 500 500 } 501 501 502 ast::Expr * build_constantStr( const CodeLocation & location, string & str ) { 502 ast::Expr * build_constantStr( 503 const CodeLocation & location, 504 string & str ) { 503 505 assert( str.length() > 0 ); 504 506 string units; // units … … 523 525 } // switch 524 526 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 } 537 535 538 536 ast::ArrayType * at = new ast::ArrayType( 539 537 strtype, 540 ast::ConstantExpr::from_ulong( location, length),538 ast::ConstantExpr::from_ulong( location, dimension ), 541 539 ast::FixedLen, 542 540 ast::DynamicDim ); 543 541 ast::Expr * ret = new ast::ConstantExpr( location, at, str, std::nullopt ); 544 542 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 } ); 546 546 } // if 547 547 -
tests/.expect/attributes.x64.txt
r262a864 r80018f5 1339 1339 __attribute__ (( noreturn )) void _X4fredFv___1(void){ 1340 1340 __attribute__ ((unused)) signed int _X1ii_2; 1341 __attribute__ ((gnu::xxx)) signed int _X1ji_2;1342 1341 switch ( 3 ) { 1343 1342 case 2: -
tests/attributes.cfa
r262a864 r80018f5 10 10 // Created On : Mon Feb 6 16:07:02 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 14:45:04202413 // Update Count : 5112 // Last Modified On : Sun Dec 15 17:45:39 2024 13 // Update Count : 49 14 14 // 15 15 … … 164 164 [[ noreturn ]] void fred() { 165 165 int [[unused]] i; 166 int [[gnu::xxx]] j;167 166 switch ( 3 ) { 168 167 case 2:
Note:
See TracChangeset
for help on using the changeset viewer.