namespace InClassInitializers { // Noexcept::Noexcept() is implicitly declared as noexcept(false), because it // directly invokes ThrowSomething(). However... // // If noexcept(Noexcept()) is false, then Noexcept() is a constant expression, // so noexcept(Noexcept()) is true. But if noexcept(Noexcept()) is true, then // Noexcept::Noexcept is not declared constexpr, therefore noexcept(Noexcept()) // is false. bool ThrowSomething() noexcept(false); struct ConstExpr { bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{exception specification is not available until end of class definition}} }; // We can use it now. bool w = noexcept(ConstExpr()); // Much more obviously broken: we can't parse the initializer without already // knowing whether it produces a noexcept expression. struct TemplateArg { int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{exception specification is not available until end of class definition}} }; bool x = noexcept(TemplateArg()); // And within a nested class. struct Nested { struct Inner { int n = ExceptionIf<noexcept(Nested())>::f(); // expected-error {{exception specification is not available until end of class definition}} } inner; }; bool y = noexcept(Nested()); bool z = noexcept(Nested::Inner()); }
void ForStat() { /* ForStat -> FOR ident := expr TO expr [ BY ConstExpr ] DO StatSeq END */ if ( debugMode) printf( "In ForStat\n"); accept( FOR_SYM, 169); accept( ident, 124); accept( assign, 133); expr(); accept( TO_SYM, 161); if ( sym == BY_SYM) { writesym(); nextsym(); ConstExpr(); } accept( DO_SYM, 166); StatSeq(); accept( END_SYM, 155); if ( debugMode) printf( "Out ForStat\n"); }
void length() { /* length -> ConstExpr */ if ( debugMode) printf( "In length\n"); ConstExpr(); if ( debugMode) printf( "Out length\n"); }
static int DoIf (int Skip) /* Process #if directive */ { ExprDesc Expr; /* We're about to abuse the compiler expression parser to evaluate the * #if expression. Save the current tokens to come back here later. * NOTE: Yes, this is a hack, but it saves a complete separate expression * evaluation for the preprocessor. */ Token SavedCurTok = CurTok; Token SavedNextTok = NextTok; /* Make sure the line infos for the tokens won't get removed */ if (SavedCurTok.LI) { UseLineInfo (SavedCurTok.LI); } if (SavedNextTok.LI) { UseLineInfo (SavedNextTok.LI); } /* Switch into special preprocessing mode */ Preprocessing = 1; /* Expand macros in this line */ PreprocessLine (); /* Add two semicolons as sentinels to the line, so the following * expression evaluation will eat these two tokens but nothing from * the following line. */ SB_AppendStr (Line, ";;"); SB_Terminate (Line); /* Load CurTok and NextTok with tokens from the new input */ NextToken (); NextToken (); /* Call the expression parser */ ConstExpr (hie1, &Expr); /* End preprocessing mode */ Preprocessing = 0; /* Reset the old tokens */ CurTok = SavedCurTok; NextTok = SavedNextTok; /* Set the #if condition according to the expression result */ return PushIf (Skip, 1, Expr.IVal != 0); }
void ConstDecl() { /* ConstDecl -> identdef = ConstExpr */ if ( debugMode) printf( "In ConstDecl\n"); identdef(); accept( equal, 123); ConstExpr(); if ( debugMode) printf( "Out ConstDecl\n"); }
local FIELDPTR InitBitField( FIELDPTR field ) { TYPEPTR typ; unsigned long value; unsigned long size; uint64 value64; unsigned long bit_value; unsigned long offset; TOKEN token; int is64bit; token = CurToken; if( CurToken == T_LEFT_BRACE ) NextToken(); typ = field->field_type; size = SizeOfArg( typ ); is64bit = ( typ->u.f.field_type == TYPE_LONG64 ) || ( typ->u.f.field_type == TYPE_ULONG64 ); if( is64bit ) U32ToU64( 0, &value64 ); offset = field->offset; value = 0; while( typ->decl_type == TYPE_FIELD || typ->decl_type == TYPE_UFIELD ) { bit_value = 0; if( CurToken != T_RIGHT_BRACE ) bit_value = ConstExpr(); if( typ->u.f.field_type == TYPE_BOOL ) { if( bit_value != 0 ) { bit_value = 1; } } else { ChkConstant( bit_value, BitMask[typ->u.f.field_width - 1] ); bit_value &= BitMask[typ->u.f.field_width - 1]; } if( is64bit ) { uint64 tmp; U32ToU64( bit_value, &tmp ); U64ShiftL( &tmp, typ->u.f.field_start, &tmp ); value64.u._32[L] |= tmp.u._32[L]; value64.u._32[H] |= tmp.u._32[H]; } else { value |= bit_value << typ->u.f.field_start; } field = field->next_field; if( field == NULL ) break; if( field->offset != offset ) break; /* bit field done */ typ = field->field_type; if( CurToken == T_EOF ) break; if( CurToken != T_RIGHT_BRACE ) { MustRecog( T_COMMA ); } } if( is64bit ) { StoreIValue64( typ->u.f.field_type, value64 ); } else { StoreIValue( typ->u.f.field_type, value, size ); } if( token == T_LEFT_BRACE ) { if( CurToken == T_COMMA ) NextToken(); MustRecog( T_RIGHT_BRACE ); } return( field ); }
void CpParameter( void ) { //===================== // Compile PARAMETER statement. // // PARAMETER (P1=E1,...,Pn=En), n > 0 uint parm_size; byte *lit; byte *string; int lit_len; sym_id sym; sym_id value_id; TYPE typ; byte assign_val; ReqNOpn(); AdvanceITPtr(); ReqOpenParen(); for(;;) { if( ReqName( NAME_VARIABLE ) ) { sym = LkSym(); typ = sym->u.ns.u1.s.typ; assign_val = TRUE; if( sym->u.ns.flags & (SY_USAGE | SY_SUB_PARM | SY_IN_EC) ) { IllName( sym ); assign_val = FALSE; } else if( typ == FT_STRUCTURE ) { IllType( sym ); assign_val = FALSE; } else { CkSymDeclared( sym ); } AdvanceITPtr(); ReqEquSign(); parm_size = sym->u.ns.xt.size; if( typ == FT_STRUCTURE ) { ConstExpr( FT_NO_TYPE ); } else if( _IsTypeLogical( typ ) ) { CLogicExpr(); } else if( typ == FT_CHAR ) { CCharExpr(); } else { CArithExpr(); } if( !AError && assign_val ) { if( typ == FT_CHAR ) { string = (byte *)CITNode->value.cstring.strptr; if( CITNode->size < parm_size ) { lit = FMemAlloc( parm_size ); lit_len = CITNode->size; memcpy( lit, string, lit_len ); memset( lit + lit_len, ' ', parm_size - lit_len ); value_id = STLit( lit, parm_size ); FMemFree( lit ); } else { if( parm_size == 0 ) { // *(*) parm_size = CITNode->size; } value_id = STLit( string, parm_size ); } } else { if( !_IsTypeLogical( typ ) ) { CnvTo( CITNode, typ, parm_size ); } value_id = STConst( &CITNode->value, typ, parm_size ); } sym->u.ns.flags |= SY_USAGE | SY_PARAMETER | SY_TYPE; sym->u.ns.xt.size = parm_size; sym->u.ns.si.pc.value = value_id; } } AdvanceITPtr(); if( !RecComma() ) break; } ReqCloseParen(); if( ReqNOpn() ) { AdvanceITPtr(); ReqEOS(); } }