Changeset f6e3e34 for src/Parser


Ignore:
Timestamp:
Apr 3, 2018, 11:13:10 AM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
92fea32
Parents:
3d2b7bc
Message:

Add StaticAssertDecl? node

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r3d2b7bc rf6e3e34  
    7171        attr.expr = nullptr;
    7272        attr.type = nullptr;
     73
     74        assert.condition = nullptr;
     75        assert.message = nullptr;
    7376}
    7477
     
    8891        // asmName, no delete, passed to next stage
    8992        delete initializer;
     93
     94        delete assert.condition;
     95        delete assert.message;
    9096}
    9197
     
    117123        newnode->attr.expr = maybeClone( attr.expr );
    118124        newnode->attr.type = maybeClone( attr.type );
     125
     126        newnode->assert.condition = maybeClone( assert.condition );
     127        newnode->assert.message = maybeClone( assert.message );
    119128        return newnode;
    120129} // DeclarationNode::clone
     
    434443        return newnode;
    435444}
     445
     446DeclarationNode * DeclarationNode::newStaticAssert( ExpressionNode * condition, Expression * message ) {
     447        DeclarationNode * newnode = new DeclarationNode;
     448        newnode->assert.condition = condition;
     449        newnode->assert.message = message;
     450        return newnode;
     451}
     452
    436453
    437454void appendError( string & dst, const string & src ) {
     
    10521069        } // if
    10531070
     1071        if ( assert.condition ) {
     1072                return new StaticAssertDecl( maybeBuild< Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) );
     1073        }
     1074
    10541075        // SUE's cannot have function specifiers, either
    10551076        //
  • src/Parser/ParseNode.h

    r3d2b7bc rf6e3e34  
    246246        static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    247247        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
     248        static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message );
    248249
    249250        DeclarationNode();
     
    313314        Attr_t attr;
    314315
     316        struct StaticAssert_t {
     317                ExpressionNode * condition;
     318                Expression * message;
     319        };
     320        StaticAssert_t assert;
     321
    315322        BuiltinType builtin;
    316323
  • src/Parser/parser.yy

    r3d2b7bc rf6e3e34  
    13081308static_assert:
    13091309        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1310                 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1310                { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
    13111311
    13121312// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
Note: See TracChangeset for help on using the changeset viewer.