Changeset 366f5cd for src/Parser


Ignore:
Timestamp:
Jun 23, 2026, 1:57:51 PM (31 hours ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
9d7a19f
Parents:
45d0e65
Message:

differentiate between C _Alignof and gcc alignof

Location:
src/Parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cpp

    r45d0e65 r366f5cd  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May  1 11:07:48 2026
    13 // Update Count     : 1128
     12// Last Modified On : Mon Jun 22 16:30:56 2026
     13// Update Count     : 1129
    1414//
    1515
     
    591591static const char * OperName[] = {                                              // must harmonize with OperKinds
    592592        // diadic
    593         "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
     593        "SizeOf", "AlignOf", "__alignof", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
    594594        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    595595        "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
  • src/Parser/ParseNode.hpp

    r45d0e65 r366f5cd  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec  9 17:39:34 2023
    13 // Update Count     : 945
     12// Last Modified On : Tue Jun 23 07:43:13 2026
     13// Update Count     : 947
    1414//
    1515
     
    9494enum class OperKinds {
    9595        // diadic
    96         SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
     96        SizeOf, AlignOf, __AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
    9797        BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    9898        Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
  • src/Parser/lex.ll

    r45d0e65 r366f5cd  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Jun  5 22:38:35 2025
    13  * Update Count     : 885
     12 * Last Modified On : Tue Jun 23 07:44:07 2026
     13 * Update Count     : 888
    1414 */
    1515
     
    5656string * build_postfix_name( string * name );
    5757
    58 char *yyfilename;
    59 string *strtext;                                                                                // accumulate parts of character and string constant value
     58char * yyfilename;
     59string * strtext;                                                                               // accumulate parts of character and string constant value
    6060
    6161#define RETURN_LOCN(x)          yylval.tok.loc.file = yyfilename; yylval.tok.loc.line = yylineno; return( x )
     
    225225alignas                 { KEYWORD_RETURN(ALIGNAS); }                    // CFA
    226226_Alignas                { KEYWORD_RETURN(ALIGNAS); }                    // C11
    227 alignof                 { KEYWORD_RETURN(ALIGNOF); }                    // CFA
     227alignof                 { KEYWORD_RETURN(ALIGNOF); }                    // C23
    228228_Alignof                { KEYWORD_RETURN(ALIGNOF); }                    // C11
    229 __alignof               { KEYWORD_RETURN(ALIGNOF); }                    // GCC
    230 __alignof__             { KEYWORD_RETURN(ALIGNOF); }                    // GCC
     229__alignof               { KEYWORD_RETURN(__ALIGNOF); }                  // GCC
     230__alignof__             { KEYWORD_RETURN(__ALIGNOF); }                  // GCC
    231231and                             { QKEYWORD_RETURN(WAND); }                              // CFA
    232232asm                             { KEYWORD_RETURN(ASM); }
  • src/Parser/parser.yy

    r45d0e65 r366f5cd  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May  1 11:01:45 2026
    13 // Update Count     : 7320
     12// Last Modified On : Tue Jun 23 12:37:08 2026
     13// Update Count     : 7350
    1414//
    1515
     
    393393%token DISABLE ENABLE TRY THROW THROWRESUME AT                  // CFA
    394394%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    395 %token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
     395%token ALIGNAS ALIGNOF __ALIGNOF GENERIC STATICASSERT   // C11/C23
    396396
    397397// names and constants: lexer differentiates between identifier and typedef names
     
    432432%type<expr> constant
    433433%type<expr> tuple                                               tuple_expression_list
    434 %type<oper> ptrref_operator                             unary_operator                          assignment_operator                     simple_assignment_operator      compound_assignment_operator
     434%type<oper> ptrref_operator                             alignof_operator                        unary_operator                          assignment_operator                     simple_assignment_operator      compound_assignment_operator
    435435%type<expr> primary_expression                  postfix_expression                      unary_expression
    436436%type<expr> cast_expression_list                cast_expression                         exponential_expression          multiplicative_expression       additive_expression
     
    933933        | SIZEOF '(' attribute_list type_no_function ')'
    934934                { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $4->addQualifiers( $3 ) ) ) ); }
    935         | ALIGNOF unary_expression                                                      // GCC, variable alignment
    936                 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, new ast::TypeofType( maybeMoveBuild( $2 ) ) ) ); }
    937         | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    938                 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     935        | alignof_operator unary_expression                                             // GCC, variable alignment
     936                { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, new ast::TypeofType( maybeMoveBuild( $2 ) ),
     937                                        $1 == OperKinds::AlignOf ? ast::AlignofExpr::Alignof : ast::AlignofExpr::__Alignof ) ); }
     938        | alignof_operator '(' type_no_function ')'                                     // GCC, type alignment
     939                { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ),
     940                                        $1 == OperKinds::AlignOf ? ast::AlignofExpr::Alignof : ast::AlignofExpr::__Alignof ) ); }
    939941
    940942                // Cannot use rule "type", which includes cfa_abstract_function, for sizeof/alignof, because of S/R problems on
     
    942944        | SIZEOF '(' cfa_abstract_function ')'
    943945                { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
    944         | ALIGNOF '(' cfa_abstract_function ')'                         // GCC, type alignment
    945                 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
    946 
     946        | alignof_operator '(' cfa_abstract_function ')'                        // GCC, type alignment
     947                { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ),
     948                                        $1 == OperKinds::AlignOf ? ast::AlignofExpr::Alignof : ast::AlignofExpr::__Alignof ) ); }
    947949        | OFFSETOF '(' type_no_function ',' identifier ')'
    948950                { $$ = new ExpressionNode( build_offsetOf( yylloc, $3, build_varref( yylloc, $5 ) ) ); }
     
    956958        | COUNTOF '(' type_no_function ')'
    957959                { $$ = new ExpressionNode( new ast::CountofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     960        ;
     961
     962alignof_operator:
     963        ALIGNOF                                                                         { $$ = OperKinds::AlignOf; }
     964        | __ALIGNOF                                                                     { $$ = OperKinds::__AlignOf; }
    958965        ;
    959966
Note: See TracChangeset for help on using the changeset viewer.