Changeset da7fe39 for src/Parser


Ignore:
Timestamp:
Apr 23, 2018, 12:57:46 PM (6 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:
57acae0
Parents:
ba89e9b7 (diff), c8ad5d9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rba89e9b7 rda7fe39  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:37:17 2018
    13 // Update Count     : 1033
     12// Last Modified On : Fri Apr 20 22:37:20 2018
     13// Update Count     : 1063
    1414//
    1515
     
    4747const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };
    4848const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };
    49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "NoBuiltinTypeNames" };
     49const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "zero_t", "one_t", "NoBuiltinTypeNames" };
    5050
    5151UniqueName DeclarationNode::anonymous( "__anonymous" );
     
    561561
    562562        checkQualifiers( type, q->type );
     563        if ( (builtin == Zero || builtin == One) && error.length() == 0 ) {
     564                SemanticWarning( yylloc, Warning::BadQualifiersZeroOne, Type::QualifiersNames[ilog2( q->type->qualifiers.val )], builtinTypeNames[builtin] );
     565//              appendError( error, string( "questionable qualifiers" ) );
     566        } // if
    563567        addQualifiersToType( q->type, type );
    564568
     
    924928                                delete newType->aggInst.aggregate->enumeration.constants;
    925929                                newType->aggInst.aggregate->enumeration.constants = nullptr;
     930                                newType->aggInst.aggregate->enumeration.body = false;
    926931                        } else {
    927932                                assert( newType->aggInst.aggregate->kind == TypeData::Aggregate );
    928933                                delete newType->aggInst.aggregate->aggregate.fields;
    929934                                newType->aggInst.aggregate->aggregate.fields = nullptr;
     935                                newType->aggInst.aggregate->aggregate.body = false;
    930936                        } // if
    931937                        // don't hoist twice
  • src/Parser/ExpressionNode.cc

    rba89e9b7 rda7fe39  
    211211        if ( Unsigned && size < 2 ) {                                           // hh or h, less than int ?
    212212                // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values.
    213                 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );
     213                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
    214214        } else if ( lnth != -1 ) {                                                      // explicit length ?
    215215                if ( lnth == 5 ) {                                                              // int128 ?
    216216                        size = 5;
    217                         ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );
     217                        ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
    218218                } else {
    219                         ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ) );
     219                        ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ), false );
    220220                } // if
    221221        } // if
     
    285285        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
    286286        if ( lnth != -1 ) {                                                                     // explicit length ?
    287                 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ) );
     287                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ), false );
    288288        } // if
    289289
     
    408408        if ( dynamic_cast< VoidType * >( targetType ) ) {
    409409                delete targetType;
    410                 return new CastExpr( maybeMoveBuild< Expression >(expr_node) );
     410                return new CastExpr( maybeMoveBuild< Expression >(expr_node), false );
    411411        } else {
    412                 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );
     412                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false );
    413413        } // if
    414414} // build_cast
     415
     416Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) {
     417        return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target );
     418}
    415419
    416420Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
  • src/Parser/ParseNode.h

    rba89e9b7 rda7fe39  
    179179
    180180Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
     181Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node );
    181182Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    182183Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
  • src/Parser/TypeData.cc

    rba89e9b7 rda7fe39  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:49:00 2018
    13 // Update Count     : 597
     12// Last Modified On : Tue Apr 17 23:00:52 2018
     13// Update Count     : 602
    1414//
    1515
     
    395395                break;
    396396          case Builtin:
    397                 os << "gcc builtin type";
     397                os << DeclarationNode::builtinTypeNames[builtintype];
    398398                break;
    399399          default:
     
    490490        switch ( td->kind ) {
    491491          case TypeData::Aggregate:
    492                 if ( ! toplevel && td->aggregate.fields ) {
     492                if ( ! toplevel && td->aggregate.body ) {
    493493                        ret = td->clone();
    494494                } // if
    495495                break;
    496496          case TypeData::Enum:
    497                 if ( ! toplevel && td->enumeration.constants ) {
     497                if ( ! toplevel && td->enumeration.body ) {
    498498                        ret = td->clone();
    499499                } // if
  • src/Parser/lex.ll

    rba89e9b7 rda7fe39  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Mar 22 16:47:06 2018
    13  * Update Count     : 668
     12 * Last Modified On : Fri Apr  6 15:16:15 2018
     13 * Update Count     : 670
    1414 */
    1515
     
    198198__asm                   { KEYWORD_RETURN(ASM); }                                // GCC
    199199__asm__                 { KEYWORD_RETURN(ASM); }                                // GCC
    200 _At                             { KEYWORD_RETURN(AT); }                                 // CFA
    201200_Atomic                 { KEYWORD_RETURN(ATOMIC); }                             // C11
    202201__attribute             { KEYWORD_RETURN(ATTRIBUTE); }                  // GCC
     
    229228exception               { KEYWORD_RETURN(EXCEPTION); }                  // CFA
    230229extern                  { KEYWORD_RETURN(EXTERN); }
     230fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    231231fallthru                { KEYWORD_RETURN(FALLTHRU); }                   // CFA
    232 fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    233232finally                 { KEYWORD_RETURN(FINALLY); }                    // CFA
    234233float                   { KEYWORD_RETURN(FLOAT); }
     
    260259__builtin_offsetof { KEYWORD_RETURN(OFFSETOF); }                // GCC
    261260one_t                   { NUMERIC_RETURN(ONE_T); }                              // CFA
     261or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    262262otype                   { KEYWORD_RETURN(OTYPE); }                              // CFA
    263263register                { KEYWORD_RETURN(REGISTER); }
     
    296296__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    297297waitfor                 { KEYWORD_RETURN(WAITFOR); }
    298 or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    299298when                    { KEYWORD_RETURN(WHEN); }
    300299while                   { KEYWORD_RETURN(WHILE); }
  • src/Parser/parser.yy

    rba89e9b7 rda7fe39  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 22 16:56:21 2018
    13 // Update Count     : 3125
     12// Last Modified On : Tue Apr 17 17:10:30 2018
     13// Update Count     : 3144
    1414//
    1515
     
    391391%precedence '('
    392392
    393 %locations                      // support location tracking for error messages
     393%locations                                                                                              // support location tracking for error messages
    394394
    395395%start translation_unit                                                                 // parse-tree root
     
    497497                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    498498        | type_name '.' no_attr_identifier                                      // CFA, nested type
    499                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     499                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    500500        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    501                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     501                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    502502        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    503                 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
     503                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
    504504        ;
    505505
     
    687687        | '(' type_no_function ')' cast_expression
    688688                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     689        | '(' COROUTINE '&' ')' cast_expression                         // CFA
     690                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
     691        | '(' THREAD '&' ')' cast_expression                            // CFA
     692                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }
     693        | '(' MONITOR '&' ')' cast_expression                           // CFA
     694                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }
    689695                // VIRTUAL cannot be opt because of look ahead issues
    690         | '(' VIRTUAL ')' cast_expression
     696        | '(' VIRTUAL ')' cast_expression                                       // CFA
    691697                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    692         | '(' VIRTUAL type_no_function ')' cast_expression
     698        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    693699                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); }
    694700//      | '(' type_no_function ')' tuple
     
    782788        | logical_OR_expression '?' comma_expression ':' conditional_expression
    783789                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    784                 // FIX ME: this hack computes $1 twice
     790                // FIX ME: computes $1 twice
    785791        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    786792                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     
    797803                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    798804        | unary_expression '=' '{' initializer_list comma_opt '}'
    799                 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
     805                { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; }
    800806        ;
    801807
     
    867873        | exception_statement
    868874        | enable_disable_statement
    869                 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     875                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; }
    870876        | asm_statement
    871877        ;
     
    10621068                { $$ = new StatementNode( build_return( $2 ) ); }
    10631069        | RETURN '{' initializer_list comma_opt '}'
    1064                 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1070                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    10651071        | THROW assignment_expression_opt ';'                           // handles rethrow
    10661072                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    10861092mutex_statement:
    10871093        MUTEX '(' argument_expression_list ')' statement
    1088                 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1094                { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; }
    10891095        ;
    10901096
     
    17021708        | LONG
    17031709                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
    1704         | ZERO_T
    1705                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    1706         | ONE_T
    1707                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17081710        | VALIST                                                                                        // GCC, __builtin_va_list
    17091711                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     
    17251727basic_type_specifier:
    17261728        direct_type
     1729                // Cannot have type modifiers, e.g., short, long, etc.
    17271730        | type_qualifier_list_opt indirect_type type_qualifier_list_opt
    17281731                { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); }
     
    17301733
    17311734direct_type:
    1732                 // A semantic check is necessary for conflicting type qualifiers.
    17331735        basic_type_name
    17341736        | type_qualifier_list basic_type_name
     
    17491751        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
    17501752                { $$ = DeclarationNode::newAttr( $1, $3 ); }
     1753        | ZERO_T                                                                                        // CFA
     1754                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     1755        | ONE_T                                                                                         // CFA
     1756                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17511757        ;
    17521758
Note: See TracChangeset for help on using the changeset viewer.