Changeset e874605 for src/Parser


Ignore:
Timestamp:
Oct 28, 2022, 3:11:57 PM (19 months ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master
Children:
93d2219
Parents:
77de429
Message:

Add class InlineValueDecl?, which is a Declaration class that works as a placeholder for aggregration value inherited from other aggregration. Disable inline value overwrite.

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r77de429 re874605  
    2727#include "SynTree/LinkageSpec.h"   // for Spec, linkageName, Cforall
    2828#include "SynTree/Attribute.h"     // for Attribute
    29 #include "SynTree/Declaration.h"   // for TypeDecl, ObjectDecl, Declaration
     29#include "SynTree/Declaration.h"   // for TypeDecl, ObjectDecl, InlineValueDecl, Declaration
    3030#include "SynTree/Expression.h"    // for Expression, ConstantExpr
    3131#include "SynTree/Statement.h"     // for AsmStmt
     
    11651165                SemanticError( this, "invalid function specifier for " );
    11661166        } // if
     1167        if ( enumInLine ) {
     1168                return new InlineValueDecl( *name, storageClasses, linkage, nullptr );
     1169        } // if
    11671170        assertf( name, "ObjectDecl must a have name\n" );
    11681171        return (new ObjectDecl( *name, storageClasses, linkage, maybeBuild< Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_asmName( asmName )->set_extension( extension );
  • src/Parser/ExpressionNode.cc

    r77de429 re874605  
    519519                }
    520520        }
    521         auto ret =  new QualifiedNameExpr( newDecl, name->name );
    522         if ( auto e = dynamic_cast<EnumDecl*>(newDecl) ) {
    523                 auto enumInst = new EnumInstType( Type::Qualifiers(), e );
    524                 auto obj = new ObjectDecl( name->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, enumInst, nullptr );
    525         }
    526         return ret;
     521        return new QualifiedNameExpr( newDecl, name->name );
    527522}
    528523
  • src/Parser/TypeData.cc

    r77de429 re874605  
    925925        for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
    926926                if ( cur->enumInLine ) {
    927                         // Tell the compiler this is a inline value placeholder
    928                         ObjectDecl * member = dynamic_cast< ObjectDecl* >(* members);
    929                         member->enumInLine = true;
    930                 }
    931                 if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) {
     927                        // Do Nothing
     928                } else if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) {
    932929                        SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." );
    933930                } else if ( cur->has_enumeratorValue() ) {
Note: See TracChangeset for help on using the changeset viewer.