Changeset 366f5cd


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

differentiate between C _Alignof and gcc alignof

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r45d0e65 r366f5cd  
    1111// Last Modified By : Peter A. Buhr
    1212// Created On       : Wed May 18 13:56:00 2022
    13 // Update Count     : 12
     13// Update Count     : 18
    1414//
    1515
     
    4646// --- ApplicationExpr
    4747
    48 ApplicationExpr::ApplicationExpr( const CodeLocation & loc, const Expr * f,
    49         std::vector<ptr<Expr>> && as )
    50 : Expr( loc ), func( f ), args( std::move(as) ) {
     48ApplicationExpr::ApplicationExpr( const CodeLocation & loc, const Expr * f,     std::vector<ptr<Expr>> && as )
     49                : Expr( loc ), func( f ), args( std::move(as) ) {
    5150        // ensure that `ApplicationExpr` result type is `FuncExpr`
    5251        const PointerType * pt = strict_dynamic_cast< const PointerType * >( f->result.get() );
     
    103102}
    104103
    105 UntypedExpr * UntypedExpr::createCall( const CodeLocation & loc,
    106                 const std::string & name, std::vector<ptr<Expr>> && args ) {
     104UntypedExpr * UntypedExpr::createCall( const CodeLocation & loc, const std::string & name, std::vector<ptr<Expr>> && args ) {
    107105        return new UntypedExpr( loc,
    108106                        new NameExpr( loc, name ), std::move( args ) );
     
    111109// --- VariableExpr
    112110
    113 VariableExpr::VariableExpr( const CodeLocation & loc )
    114 : Expr( loc ), var( nullptr ) {}
    115 
    116 VariableExpr::VariableExpr( const CodeLocation & loc, const DeclWithType * v )
    117 : Expr( loc ), var( v ) {
     111VariableExpr::VariableExpr( const CodeLocation & loc ) : Expr( loc ), var( nullptr ) {}
     112
     113VariableExpr::VariableExpr( const CodeLocation & loc, const DeclWithType * v ) : Expr( loc ), var( v ) {
    118114        assert( var );
    119115        assert( var->get_type() );
     
    130126}
    131127
    132 VariableExpr * VariableExpr::functionPointer(
    133                 const CodeLocation & loc, const FunctionDecl * decl ) {
     128VariableExpr * VariableExpr::functionPointer( const CodeLocation & loc, const FunctionDecl * decl ) {
    134129        // wrap usually-determined result type in a pointer
    135130        VariableExpr * funcExpr = new VariableExpr{ loc, decl };
     
    178173}
    179174
    180 AddressExpr::AddressExpr( const CodeLocation & loc, const Expr * a ) :
    181         Expr( loc, addrExprType( loc, a ) ), arg( a )
    182 {}
     175AddressExpr::AddressExpr( const CodeLocation & loc, const Expr * a ) : Expr( loc, addrExprType( loc, a ) ), arg( a ) {}
    183176
    184177// --- LabelAddressExpr
     
    191184
    192185CastExpr::CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g, CastKind kind )
    193 : Expr( loc, new VoidType{} ), arg( a ), isGenerated( g ), kind( kind ) {}
     186                : Expr( loc, new VoidType{} ), arg( a ), isGenerated( g ), kind( kind ) {}
    194187
    195188bool CastExpr::get_lvalue() const {
     
    213206
    214207MemberExpr::MemberExpr( const CodeLocation & loc, const DeclWithType * mem, const Expr * agg )
    215 : Expr( loc ), member( mem ), aggregate( agg ) {
     208                : Expr( loc ), member( mem ), aggregate( agg ) {
    216209        assert( member );
    217210        assert( aggregate );
     
    249242
    250243ConstantExpr * ConstantExpr::from_bool( const CodeLocation & loc, bool b ) {
    251         return new ConstantExpr{
    252                 loc, new BasicType{ BasicKind::Bool }, b ? "1" : "0", (unsigned long long)b };
     244        return new ConstantExpr{ loc, new BasicType{ BasicKind::Bool }, b ? "1" : "0", (unsigned long long)b };
    253245}
    254246
    255247ConstantExpr * ConstantExpr::from_int( const CodeLocation & loc, int i ) {
    256         return new ConstantExpr{
    257                 loc, new BasicType{ BasicKind::SignedInt }, std::to_string( i ), (unsigned long long)i };
     248        return new ConstantExpr{ loc, new BasicType{ BasicKind::SignedInt }, std::to_string( i ), (unsigned long long)i };
    258249}
    259250
    260251ConstantExpr * ConstantExpr::from_ulong( const CodeLocation & loc, unsigned long i ) {
    261         return new ConstantExpr{
    262                 loc, new BasicType{ BasicKind::LongUnsignedInt }, std::to_string( i ),
    263                 (unsigned long long)i };
     252        return new ConstantExpr{ loc, new BasicType{ BasicKind::LongUnsignedInt }, std::to_string( i ), (unsigned long long)i };
    264253}
    265254
     
    274263
    275264ConstantExpr * ConstantExpr::null( const CodeLocation & loc, const Type * ptrType ) {
    276         return new ConstantExpr{
    277                 loc, ptrType ? ptrType : new PointerType{ new VoidType{} }, "0", (unsigned long long)0 };
     265        return new ConstantExpr{ loc, ptrType ? ptrType : new PointerType{ new VoidType{} }, "0", (unsigned long long)0 };
    278266}
    279267
    280268// --- SizeofExpr
    281269
    282 SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * type )
    283 : SizeofExpr( loc, type, nullptr ) {}
    284 
    285 SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * type, const Type * result )
    286 : Expr( loc, result ), type( type ) {}
     270SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * type ) : SizeofExpr( loc, type, nullptr ) {}
     271
     272SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * type, const Type * result ) : Expr( loc, result ), type( type ) {}
    287273
    288274// --- AlignofExpr
    289275
    290 AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * type )
    291 : AlignofExpr( loc, type, nullptr ) {}
    292 
    293 AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * type, const Type * result )
    294 : Expr( loc, result ), type( type ) {}
     276AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * type, const Alignment kind ) : AlignofExpr( loc, type, nullptr, kind ) {}
     277
     278AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * type, const Type * result, const Alignment kind )
     279                : Expr( loc, result ), type( type ), kind( kind ) {}
    295280
    296281// --- CountofExpr
    297282
    298 CountofExpr::CountofExpr( const CodeLocation & loc, const Type * t )
    299 : Expr( loc ), type( t ) {}
     283CountofExpr::CountofExpr( const CodeLocation & loc, const Type * t ) : Expr( loc ), type( t ) {}
    300284
    301285// --- OffsetofExpr
    302286
    303287OffsetofExpr::OffsetofExpr( const CodeLocation & loc, const Type * ty, const DeclWithType * mem, const Type * res )
    304 : Expr( loc, res ), type( ty ), member( mem ) {
     288                : Expr( loc, res ), type( ty ), member( mem ) {
    305289        assert( type );
    306290        assert( member );
     
    309293// --- OffsetPackExpr
    310294
    311 OffsetPackExpr::OffsetPackExpr( const CodeLocation & loc, const StructInstType * ty )
    312 : Expr( loc ), type( ty ) {
     295OffsetPackExpr::OffsetPackExpr( const CodeLocation & loc, const StructInstType * ty ) : Expr( loc ), type( ty ) {
    313296        assert( type );
    314297}
     
    316299// --- LogicalExpr
    317300
    318 LogicalExpr::LogicalExpr(
    319         const CodeLocation & loc, const Expr * a1, const Expr * a2, LogicalFlag ia )
    320 : Expr( loc, new BasicType{ BasicKind::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {}
     301LogicalExpr::LogicalExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2, LogicalFlag ia )
     302                : Expr( loc, new BasicType{ BasicKind::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {}
    321303
    322304// --- CommaExpr
     
    330312// --- ConstructorExpr
    331313
    332 ConstructorExpr::ConstructorExpr( const CodeLocation & loc, const Expr * call )
    333 : Expr( loc ), callExpr( call ) {
     314ConstructorExpr::ConstructorExpr( const CodeLocation & loc, const Expr * call ) : Expr( loc ), callExpr( call ) {
    334315        // allow resolver to type a constructor used as an expression if it has the same type as its
    335316        // first argument
     
    342323// --- CompoundLiteralExpr
    343324
    344 CompoundLiteralExpr::CompoundLiteralExpr( const CodeLocation & loc, const Type * t, const Init * i )
    345 : Expr( loc ), init( i ) {
     325CompoundLiteralExpr::CompoundLiteralExpr( const CodeLocation & loc, const Type * t, const Init * i ) : Expr( loc ), init( i ) {
    346326        assert( t && i );
    347327        result = t;
     
    354334// --- TupleExpr
    355335
    356 TupleExpr::TupleExpr( const CodeLocation & loc, std::vector<ptr<Expr>> && xs )
    357 : Expr( loc, Tuples::makeTupleType( xs ) ), exprs( xs ) {}
     336TupleExpr::TupleExpr( const CodeLocation & loc, std::vector<ptr<Expr>> && xs ) : Expr( loc, Tuples::makeTupleType( xs ) ), exprs( xs ) {}
    358337
    359338// --- TupleIndexExpr
    360339
    361 TupleIndexExpr::TupleIndexExpr( const CodeLocation & loc, const Expr * t, unsigned i )
    362 : Expr( loc ), tuple( t ), index( i ) {
     340TupleIndexExpr::TupleIndexExpr( const CodeLocation & loc, const Expr * t, unsigned i ) : Expr( loc ), tuple( t ), index( i ) {
    363341        const TupleType * type = strict_dynamic_cast< const TupleType * >( tuple->result.get() );
    364342        assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested "
     
    374352// --- TupleAssignExpr
    375353
    376 TupleAssignExpr::TupleAssignExpr(
    377         const CodeLocation & loc, std::vector<ptr<Expr>> && assigns,
    378         std::vector<ptr<ObjectDecl>> && tempDecls )
    379 : Expr( loc, Tuples::makeTupleType( assigns ) ), stmtExpr() {
     354TupleAssignExpr::TupleAssignExpr( const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, std::vector<ptr<ObjectDecl>> && tempDecls )
     355                : Expr( loc, Tuples::makeTupleType( assigns ) ), stmtExpr() {
    380356        // convert internally into a StmtExpr which contains the declarations and produces the tuple of
    381357        // the assignments
     
    392368// --- StmtExpr
    393369
    394 StmtExpr::StmtExpr( const CodeLocation & loc, const CompoundStmt * ss )
    395 : Expr( loc ), stmts( ss ) { computeResult(); }
     370StmtExpr::StmtExpr( const CodeLocation & loc, const CompoundStmt * ss ) : Expr( loc ), stmts( ss ) { computeResult(); }
    396371
    397372void StmtExpr::computeResult() {
     
    411386unsigned long long UniqueExpr::nextId = 0;
    412387
    413 UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i )
    414 : Expr( loc, e->result ), expr( e ), id( i ) {
     388UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i ) : Expr( loc, e->result ), expr( e ), id( i ) {
    415389        assert( expr );
    416390        if ( id == -1ull ) {
  • src/AST/Expr.hpp

    r45d0e65 r366f5cd  
    1111// Last Modified By : Peter A. Buhr
    1212// Created On       : Fri May 10 10:30:00 2019
    13 // Update Count     : 8
     13// Update Count     : 24
    1414//
    1515
     
    495495public:
    496496        ptr<Type> type;
    497 
    498         AlignofExpr( const CodeLocation & loc, const Type * t );
    499         AlignofExpr( const CodeLocation & loc, const Type * t, const Type * r );
     497        enum Alignment { Alignof, __Alignof } kind;
     498
     499        AlignofExpr( const CodeLocation & loc, const Type * t, const Alignment kind );
     500        AlignofExpr( const CodeLocation & loc, const Type * t, const Type * r, const Alignment kind );
    500501
    501502        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/CodeGen/CodeGenerator.cpp

    r45d0e65 r366f5cd  
    1010// Created On       : Tue Oct 17 15:54:00 2023
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 11 11:13:10 2026
    13 // Update Count     : 28
     12// Last Modified On : Tue Jun 23 13:42:15 2026
     13// Update Count     : 34
    1414//
    1515
     
    778778
    779779void CodeGenerator::postvisit( ast::AlignofExpr const * expr ) {
    780         // Using the GCC extension to avoid changing the std to C11.
    781         extension( expr );
    782         output << "__alignof__(";
     780        extension( expr );
     781        output << (expr->kind ? "__alignof__(" : "_Alignof(");
    783782        if ( auto type = expr->type.as<ast::TypeofType>() ) {
    784783                type->expr->accept( *visitor );
     
    790789
    791790void CodeGenerator::postvisit( ast::CountofExpr const * expr ) {
    792         assertf( !options.genC, "CountofExpr should not reach code generation." );
     791        assertf( ! options.genC, "CountofExpr should not reach code generation." );
    793792        extension( expr );
    794793        output << "countof(";
  • src/GenPoly/Box.cpp

    r45d0e65 r366f5cd  
    1010// Created On       : Thr Oct  6 13:39:00 2022
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 14 17:42:17 2023
    13 // Update Count     : 7
     12// Last Modified On : Tue Jun 23 12:31:47 2026
     13// Update Count     : 9
    1414//
    1515
     
    265265                        kids.emplace_back( makeAlignTo( location,
    266266                                derefVar( location, sizeofParam ),
    267                                 new ast::AlignofExpr( location, ast::deepCopy( memberType ) )
     267                                new ast::AlignofExpr( location, ast::deepCopy( memberType ), ast::AlignofExpr::Alignof )
    268268                        ) );
    269269                }
     
    285285                kids.emplace_back( makeAssignMax( location,
    286286                        derefVar( location, alignofParam ),
    287                         new ast::AlignofExpr( location, ast::deepCopy( memberType ) ) ) );
     287                        new ast::AlignofExpr( location, ast::deepCopy( memberType ), ast::AlignofExpr::Alignof ) ) );
    288288        }
    289289        // Make sure the type is end-padded to a multiple of its alignment.
     
    343343                kids.emplace_back( makeAssignMax( location,
    344344                        derefVar( location, alignofParam ),
    345                         new ast::AlignofExpr( location, ast::deepCopy( memberType ) )
     345                        new ast::AlignofExpr( location, ast::deepCopy( memberType ), ast::AlignofExpr::Alignof )
    346346                ) );
    347347        }
     
    807807                        new ast::SizeofExpr( expr->location, ast::deepCopy( concrete ) ) );
    808808                extraArgs.emplace_back(
    809                         new ast::AlignofExpr( expr->location, ast::deepCopy( concrete ) ) );
     809                        new ast::AlignofExpr( expr->location, ast::deepCopy( concrete ), ast::AlignofExpr::Alignof ) );
    810810        }
    811811}
     
    17231723                alignofName( typeName ), getLayoutCType( transUnit() ),
    17241724                new ast::SingleInit( decl->location,
    1725                         new ast::AlignofExpr( decl->location, deepCopy( base ) )
     1725                        new ast::AlignofExpr( decl->location, deepCopy( base ), ast::AlignofExpr::Alignof )
    17261726                )
    17271727        );
     
    21992199                                new ast::SizeofExpr( location, ast::deepCopy( param ) ) );
    22002200                        args.emplace_back(
    2201                                 new ast::AlignofExpr( location, ast::deepCopy( param ) ) );
     2201                                new ast::AlignofExpr( location, ast::deepCopy( param ), ast::AlignofExpr::Alignof ) );
    22022202                }
    22032203        }
  • 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
  • src/ResolvExpr/CandidateFinder.cpp

    r45d0e65 r366f5cd  
    1010// Created On       : Wed Jun 5 14:30:00 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  9 11:30:11 2024
    13 // Update Count     : 5
     12// Last Modified On : Tue Jun 23 11:41:24 2026
     13// Update Count     : 7
    1414//
    1515
     
    14961496                const ast::Type * type = resolveTypeof( alignofExpr->type, context );
    14971497                const ast::Type * sizeType = context.global.sizeType.get();
    1498                 addCandidate(
    1499                         new ast::AlignofExpr( alignofExpr->location, type, sizeType ),
    1500                         tenv );
     1498                addCandidate( new ast::AlignofExpr( alignofExpr->location, type, sizeType, alignofExpr->kind ), tenv );
    15011499        }
    15021500
  • src/Virtual/Tables.cpp

    r45d0e65 r366f5cd  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Aug 31 11:11:00 2020
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Mar 11 10:40:00 2022
    13 // Update Count     : 3
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Jun 23 12:31:00 2026
     13// Update Count     : 4
    1414//
    1515
     
    115115                } else if ( std::string( "align" ) == field->name ) {
    116116                        inits.push_back( new ast::SingleInit( location,
    117                                 new ast::AlignofExpr( location, objectType )
     117                                new ast::AlignofExpr( location, objectType, ast::AlignofExpr::Alignof )
    118118                        ) );
    119119                } else {
Note: See TracChangeset for help on using the changeset viewer.