Ignore:
Timestamp:
Feb 28, 2022, 3:41:44 AM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
786c438
Parents:
a8ef59e
Message:

The compiler is now trying to pass the value of enum const to code gen; but it won't work cause we must be able to evaluate the const_expr in compiler time. It is not currently passed as a Expression but won't be able to evaluate at compile time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    ra8ef59e rf135b50  
    22922292                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    22932293                        // SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
    2294                         $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 );
     2294
     2295                        $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 )  -> addEnumBase( $3 );
     2296                        // $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 );
    22952297                }
    22962298        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier
     
    23012303          '{' enumerator_list comma_opt '}'
    23022304                {
    2303                         $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
     2305                        $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
     2306                        // $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
    23042307                }
    23052308        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
     
    23072310                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    23082311                        typedefTable.makeTypedef( *$6->name );
    2309                         $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
     2312                        $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
     2313                        // $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
    23102314                }
    23112315        | enum_type_nobody
Note: See TracChangeset for help on using the changeset viewer.