Changeset f7e4db27


Ignore:
Timestamp:
Jul 20, 2018, 3:51:48 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
f2f512ba
Parents:
dea36ee
Message:

improve error messages for useless declarations

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Parser/TypeData.cc

    rdea36ee rf7e4db27  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 18 17:51:18 2018
    13 // Update Count     : 607
     12// Last Modified On : Fri Jul 20 14:39:31 2018
     13// Update Count     : 622
    1414//
    1515
     
    271271
    272272        switch ( kind ) {
    273           case Unknown:
    274                 os << "entity of unknown type ";
     273          case Basic:
     274                if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " ";
     275                if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " ";
     276                if ( complextype == DeclarationNode::NoComplexType ) { // basic type
     277                        assert( basictype != DeclarationNode::NoBasicType );
     278                        os << DeclarationNode::basicTypeNames[ basictype ] << " ";
     279                } else {                                                                                // complex type
     280                        // handle double _Complex
     281                        if ( basictype != DeclarationNode::NoBasicType ) os << DeclarationNode::basicTypeNames[ basictype ] << " ";
     282                        os << DeclarationNode::complexTypeNames[ complextype ] << " ";
     283                } // if
    275284                break;
    276285          case Pointer:
     
    281290                } // if
    282291                break;
    283           case EnumConstant:
    284                 os << "enumeration constant ";
    285                 break;
    286           case Basic:
    287                 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " ";
    288                 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " ";
    289                 assert( basictype != DeclarationNode::NoBasicType );
    290                 os << DeclarationNode::basicTypeNames[ basictype ] << " ";
    291                 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeNames[ complextype ] << " ";
     292          case Reference:
     293                os << "reference ";
     294                if ( base ) {
     295                        os << "to ";
     296                        base->print( os, indent );
     297                } // if
    292298                break;
    293299          case Array:
     
    375381                } // if
    376382                break;
    377           case SymbolicInst:
    378                 os << "instance of type " << *symbolic.name;
    379                 if ( symbolic.actuals ) {
    380                         os << " with parameters" << endl;
    381                         symbolic.actuals->printList( os, indent + 2 );
    382                 } // if
     383          case EnumConstant:
     384                os << "enumeration constant ";
    383385                break;
    384386          case Symbolic:
     
    402404                } // if
    403405                break;
     406          case SymbolicInst:
     407                os << *symbolic.name;
     408                if ( symbolic.actuals ) {
     409                        os << "(";
     410                        symbolic.actuals->printList( os, indent + 2 );
     411                        os << ")";
     412                } // if
     413                break;
    404414          case Tuple:
    405415                os << "tuple ";
     
    417427          case Builtin:
    418428                os << DeclarationNode::builtinTypeNames[builtintype];
     429                break;
     430          case GlobalScope:
     431                break;
     432          case Qualified:
     433                qualified.parent->print( os );
     434                os << ".";
     435                qualified.child->print( os );
     436                break;
     437          case Unknown:
     438                os << "entity of unknown type ";
    419439                break;
    420440          default:
  • TabularUnified src/Parser/TypeData.h

    rdea36ee rf7e4db27  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 18 17:31:15 2018
    13 // Update Count     : 194
     12// Last Modified On : Fri Jul 20 13:56:40 2018
     13// Update Count     : 195
    1414//
    1515
     
    2626
    2727struct TypeData {
    28         enum Kind { Basic, Pointer, Array, Reference, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
     28        enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
    2929                                SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Qualified, Unknown };
    3030
     
    7777        };
    7878
    79         struct Qualified_t { // qualified type S.T
     79        struct Qualified_t {                                                            // qualified type S.T
    8080                TypeData * parent;
    8181                TypeData * child;
  • TabularUnified src/Parser/parser.yy

    rdea36ee rf7e4db27  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 19 22:21:56 2018
    13 // Update Count     : 3827
     12// Last Modified On : Fri Jul 20 11:46:46 2018
     13// Update Count     : 3837
    1414//
    1515
     
    172172        return new_name;
    173173} // build_postfix_name
     174
     175DeclarationNode * fieldDecl( DeclarationNode * typeSpec, DeclarationNode * fieldList ) {
     176        if ( ! fieldList ) {                                                            // field declarator ?
     177                if ( ! ( typeSpec->type && typeSpec->type->kind == TypeData::Aggregate ) ) {
     178                        stringstream ss;
     179                        typeSpec->type->print( ss );
     180                        SemanticWarning( yylloc, Warning::SuperfluousDecl, ss.str().c_str() );
     181                        return nullptr;
     182                } // if
     183                fieldList = DeclarationNode::newName( nullptr );
     184        } // if
     185        return distAttr( typeSpec, fieldList );                         // mark all fields in list
     186} // fieldDecl
    174187
    175188bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
     
    19421955field_declaration:
    19431956        type_specifier field_declaring_list_opt ';'
    1944                 {
    1945                         if ( ! $2 ) {                                                           // field declarator ?
    1946                                 $2 = DeclarationNode::newName( nullptr );
    1947                                 if ( ! ( $1->type && $1->type->kind == TypeData::Aggregate ) ) {
    1948                                         SemanticWarning( yylloc, Warning::SuperfluousDecl, "" );
    1949                                 } // if
    1950                         } // if
    1951                         $$ = distAttr( $1, $2 );                                        // mark all fields in list
    1952                 }
     1957                { $$ = fieldDecl( $1, $2 ); }
    19531958        | EXTENSION type_specifier field_declaring_list_opt ';' // GCC
    1954                 {
    1955                         if ( ! $3 ) {                                                           // field declarator ?
    1956                                 $3 = DeclarationNode::newName( nullptr );
    1957                                 if ( ! ( $2->type && $2->type->kind == TypeData::Aggregate ) ) {
    1958                                         SemanticWarning( yylloc, Warning::SuperfluousDecl, "" );
    1959                                 } // if
    1960                         } // if
    1961                         $$ = distAttr( $2, $3 );                                        // mark all fields in list
    1962                         distExt( $$ );
    1963                 }
     1959                { $$ = fieldDecl( $2, $3 ); distExt( $$ ); }
    19641960        | INLINE type_specifier field_abstract_list_opt ';'     // CFA
    19651961                {
     
    20092005
    20102006field_abstract:
    2011         //      no bit fields
     2007                //      no bit fields
    20122008        variable_abstract_declarator
    20132009        ;
    20142010
    20152011cfa_field_declaring_list:                                                               // CFA, new style field declaration
     2012        // bit-fields are handled by C declarations
    20162013        cfa_abstract_declarator_tuple no_attr_identifier_or_type_name
    20172014                { $$ = $1->addName( $2 ); }
     
    20212018
    20222019cfa_field_abstract_list:                                                                // CFA, new style field declaration
     2020        // bit-fields are handled by C declarations
    20232021        cfa_abstract_declarator_tuple
    20242022        | cfa_field_abstract_list ','
  • TabularUnified src/tests/.expect/attributes.x64.txt

    rdea36ee rf7e4db27  
    367367signed int __apd7__Fi_Fi_i_Fi_i___1(__attribute__ ((unused,unused,unused)) signed int (*__anonymous_object23)(__attribute__ ((unused)) signed int __anonymous_object24), __attribute__ ((unused,unused,unused)) signed int (*__anonymous_object25)(__attribute__ ((unused)) signed int __anonymous_object26));
    368368struct Vad {
    369     __attribute__ ((unused)) signed int __anonymous_object27;
     369    __attribute__ ((unused)) signed int __anonymous_object27:4;
    370370    __attribute__ ((unused)) signed int __anonymous_object28:4;
    371     __attribute__ ((unused)) signed int __anonymous_object29:4;
    372     __attribute__ ((unused,unused)) signed int __anonymous_object30:6;
     371    __attribute__ ((unused,unused)) signed int __anonymous_object29:6;
    373372};
    374373static inline void ___constructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1);
     
    376375static inline void ___destructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1);
    377376static inline struct Vad ___operator_assign__F4sVad_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1);
    378 static inline void ___constructor__F_4sVadi_autogen___1(struct Vad *___dst__4sVad_1, __attribute__ ((unused)) signed int __anonymous_object31);
    379377static inline void ___constructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1){
    380     ((void)((*___dst__4sVad_1).__anonymous_object27) /* ?{} */);
    381378}
    382379static inline void ___constructor__F_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1){
    383     ((void)((*___dst__4sVad_1).__anonymous_object27=___src__4sVad_1.__anonymous_object27) /* ?{} */);
    384380}
    385381static inline void ___destructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1){
    386     ((void)((*___dst__4sVad_1).__anonymous_object27) /* ^?{} */);
    387382}
    388383static inline struct Vad ___operator_assign__F4sVad_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1){
    389384    struct Vad ___ret__4sVad_1;
    390     ((void)((*___dst__4sVad_1).__anonymous_object27=___src__4sVad_1.__anonymous_object27));
    391385    ((void)___constructor__F_4sVad4sVad_autogen___1((&___ret__4sVad_1), (*___dst__4sVad_1)));
    392386    return ___ret__4sVad_1;
    393387}
    394 static inline void ___constructor__F_4sVadi_autogen___1(struct Vad *___dst__4sVad_1, __attribute__ ((unused)) signed int __anonymous_object32){
    395     ((void)((*___dst__4sVad_1).__anonymous_object27=__anonymous_object32) /* ?{} */);
    396 }
  • TabularUnified src/tests/.expect/declarationErrors.txt

    rdea36ee rf7e4db27  
    1717
    1818
    19 declarationErrors.c:22:1 error: duplicate static in declaration of x6: static const volatile instance of type Int
     19declarationErrors.c:22:1 error: duplicate static in declaration of x6: static const volatile Int
    2020
    2121declarationErrors.c:24:1 error: duplicate const in declaration of f01: static inline function
Note: See TracChangeset for help on using the changeset viewer.