Ignore:
Timestamp:
Mar 26, 2024, 3:17:51 PM (3 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
544b799
Parents:
84886499
Message:

Fused TypeData::Enum and TypeData::Aggregate, an enumeration is a kind of aggregate after all. There will always be some unused fields in Aggregate_t (but less in TypeData? overall) but the code is almost always simpler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r84886499 r67467a3  
    202202
    203203DeclarationNode * fieldDecl( DeclarationNode * typeSpec, DeclarationNode * fieldList ) {
    204         if ( ! fieldList ) {                                                            // field declarator ?
    205                 if ( ! ( typeSpec->type && (typeSpec->type->kind == TypeData::Aggregate || typeSpec->type->kind == TypeData::Enum) ) ) {
     204        if ( nullptr == fieldList ) {
     205                if ( !( typeSpec->type && typeSpec->type->kind == TypeData::Aggregate ) ) {
    206206                        stringstream ss;
    207207                        // printf( "fieldDecl1 typeSpec %p\n", typeSpec ); typeSpec->type->print( std::cout );
     
    21732173                {
    21742174                        SemanticError( yylloc, "syntax error, expecting ';' at end of \"%s\" declaration.",
    2175                                                    $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ) );
     2175                                                   ast::AggregateDecl::aggrString( $1->type->aggregate.kind ) );
    21762176                        $$ = nullptr;
    21772177                }
     
    32453245                        if ( $1->linkage == ast::Linkage::Cforall && ! $1->storageClasses.is_static &&
    32463246                                 $1->type && $1->type->kind == TypeData::AggregateInst ) {
    3247                                 if ( $1->type->aggInst.aggregate->kind == TypeData::Enum && $1->type->aggInst.aggregate->enumeration.anon ) {
    3248                                         SemanticError( yylloc, "extern anonymous enumeration is currently unimplemented." ); $$ = nullptr;
    3249                                 } else if ( $1->type->aggInst.aggregate->aggregate.anon ) { // handles struct or union
    3250                                         SemanticError( yylloc, "extern anonymous struct/union is currently unimplemented." ); $$ = nullptr;
     3247                                if ( $1->type->aggInst.aggregate->aggregate.anon ) {
     3248                                        SemanticError( yylloc, "extern anonymous aggregate is currently unimplemented." ); $$ = nullptr;
    32513249                                }
    32523250                        }
Note: See TracChangeset for help on using the changeset viewer.