Changes in / [3403534:f04a8b81]


Ignore:
Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/PolyMutator.cc

    r3403534 rf04a8b81  
    3030
    3131        void PolyMutator::mutateStatementList( std::list< Statement* > &statements ) {
     32                SemanticError errors;
     33
    3234                for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
    3335                        if ( ! stmtsToAddAfter.empty() ) {
    3436                                statements.splice( i, stmtsToAddAfter );
    3537                        } // if
    36                         *i = (*i)->acceptMutator( *this );
     38                        try {
     39                                *i = (*i)->acceptMutator( *this );
     40                        } catch ( SemanticError &e ) {
     41                                errors.append( e );
     42                        } // try
    3743                        if ( ! stmtsToAdd.empty() ) {
    3844                                statements.splice( i, stmtsToAdd );
     
    4248                        statements.splice( statements.end(), stmtsToAddAfter );
    4349                } // if
     50                if ( ! errors.isEmpty() ) {
     51                        throw errors;
     52                }
    4453        }
    4554
  • src/InitTweak/GenInit.cc

    r3403534 rf04a8b81  
    245245                        // constructed objects cannot be designated
    246246                        if ( isDesignated( objDecl->get_init() ) ) throw SemanticError( "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.", objDecl );
    247                         // xxx - constructed objects should not have initializers nested too deeply
     247                        // constructed objects should not have initializers nested too deeply
     248                        if ( ! checkInitDepth( objDecl ) ) throw SemanticError( "Managed object's initializer is too deep ", objDecl );
    248249
    249250                        // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
  • src/InitTweak/InitTweak.cc

    r3403534 rf04a8b81  
    2323                };
    2424
     25                class InitDepthChecker : public Visitor {
     26                public:
     27                        bool depthOkay = true;
     28                        Type * type;
     29                        int curDepth = 0, maxDepth = 0;
     30                        InitDepthChecker( Type * type ) : type( type ) {
     31                                Type * t = type;
     32                                while ( ArrayType * at = dynamic_cast< ArrayType * >( t ) ) {
     33                                        maxDepth++;
     34                                        t = at->get_base();
     35                                }
     36                                maxDepth++;
     37                        }
     38                        virtual void visit( ListInit * listInit ) {
     39                                curDepth++;
     40                                if ( curDepth > maxDepth ) depthOkay = false;
     41                                Visitor::visit( listInit );
     42                                curDepth--;
     43                        }
     44                };
     45
    2546                class InitFlattener : public Visitor {
    2647                        public:
     
    5374                maybeAccept( init, finder );
    5475                return finder.hasDesignations;
     76        }
     77
     78        bool checkInitDepth( ObjectDecl * objDecl ) {
     79                InitDepthChecker checker( objDecl->get_type() );
     80                maybeAccept( objDecl->get_init(), checker );
     81                return checker.depthOkay;
    5582        }
    5683
  • src/InitTweak/InitTweak.h

    r3403534 rf04a8b81  
    4040        /// True if the Initializer contains designations
    4141        bool isDesignated( Initializer * init );
     42
     43        /// True if the ObjectDecl's Initializer nesting level is not deeper than the depth of its
     44        /// type, where the depth of its type is the number of nested ArrayTypes + 1
     45        bool checkInitDepth( ObjectDecl * objDecl );
    4246
    4347  /// Non-Null if expr is a call expression whose target function is intrinsic
  • src/tests/.expect/32/declarationSpecifier.txt

    r3403534 rf04a8b81  
    530530    return ((int )_retVal0);
    531531}
    532 __attribute__ ((constructor(),)) static void _init_declarationSpecifier(void){
    533     ((void)___constructor__F_P13s__anonymous0_autogen___1(((struct __anonymous0 *)(&__x10__CV13s__anonymous0_1))));
    534     ((void)___constructor__F_P13s__anonymous1_autogen___1(((struct __anonymous1 *)(&__x11__CV13s__anonymous1_1))));
    535     ((void)___constructor__F_P13s__anonymous2_autogen___1(((struct __anonymous2 *)(&__x12__CV13s__anonymous2_1))));
    536     ((void)___constructor__F_P13s__anonymous3_autogen___1(((struct __anonymous3 *)(&__x13__CV13s__anonymous3_1))));
    537     ((void)___constructor__F_P13s__anonymous4_autogen___1(((struct __anonymous4 *)(&__x14__CV13s__anonymous4_1))));
    538     ((void)___constructor__F_P13s__anonymous5_autogen___1(((struct __anonymous5 *)(&__x15__CV13s__anonymous5_1))));
    539     ((void)___constructor__F_P13s__anonymous6_autogen___1(((struct __anonymous6 *)(&__x16__CV13s__anonymous6_1))));
    540     ((void)___constructor__F_P13s__anonymous7_autogen___1(((struct __anonymous7 *)(&__x17__CV13s__anonymous7_1))));
    541     ((void)___constructor__F_P13s__anonymous8_autogen___1(((struct __anonymous8 *)(&__x29__CV13s__anonymous8_1))));
    542     ((void)___constructor__F_P13s__anonymous9_autogen___1(((struct __anonymous9 *)(&__x30__CV13s__anonymous9_1))));
    543     ((void)___constructor__F_P14s__anonymous10_autogen___1(((struct __anonymous10 *)(&__x31__CV14s__anonymous10_1))));
    544     ((void)___constructor__F_P14s__anonymous11_autogen___1(((struct __anonymous11 *)(&__x32__CV14s__anonymous11_1))));
    545     ((void)___constructor__F_P14s__anonymous12_autogen___1(((struct __anonymous12 *)(&__x33__CV14s__anonymous12_1))));
    546     ((void)___constructor__F_P14s__anonymous13_autogen___1(((struct __anonymous13 *)(&__x34__CV14s__anonymous13_1))));
    547     ((void)___constructor__F_P14s__anonymous14_autogen___1(((struct __anonymous14 *)(&__x35__CV14s__anonymous14_1))));
    548     ((void)___constructor__F_P14s__anonymous15_autogen___1(((struct __anonymous15 *)(&__x36__CV14s__anonymous15_1))));
    549 }
    550 __attribute__ ((destructor(),)) static void _destroy_declarationSpecifier(void){
    551     ((void)___destructor__F_P14s__anonymous15_autogen___1(((struct __anonymous15 *)(&__x36__CV14s__anonymous15_1))));
    552     ((void)___destructor__F_P14s__anonymous14_autogen___1(((struct __anonymous14 *)(&__x35__CV14s__anonymous14_1))));
    553     ((void)___destructor__F_P14s__anonymous13_autogen___1(((struct __anonymous13 *)(&__x34__CV14s__anonymous13_1))));
    554     ((void)___destructor__F_P14s__anonymous12_autogen___1(((struct __anonymous12 *)(&__x33__CV14s__anonymous12_1))));
    555     ((void)___destructor__F_P14s__anonymous11_autogen___1(((struct __anonymous11 *)(&__x32__CV14s__anonymous11_1))));
    556     ((void)___destructor__F_P14s__anonymous10_autogen___1(((struct __anonymous10 *)(&__x31__CV14s__anonymous10_1))));
    557     ((void)___destructor__F_P13s__anonymous9_autogen___1(((struct __anonymous9 *)(&__x30__CV13s__anonymous9_1))));
    558     ((void)___destructor__F_P13s__anonymous8_autogen___1(((struct __anonymous8 *)(&__x29__CV13s__anonymous8_1))));
    559     ((void)___destructor__F_P13s__anonymous7_autogen___1(((struct __anonymous7 *)(&__x17__CV13s__anonymous7_1))));
    560     ((void)___destructor__F_P13s__anonymous6_autogen___1(((struct __anonymous6 *)(&__x16__CV13s__anonymous6_1))));
    561     ((void)___destructor__F_P13s__anonymous5_autogen___1(((struct __anonymous5 *)(&__x15__CV13s__anonymous5_1))));
    562     ((void)___destructor__F_P13s__anonymous4_autogen___1(((struct __anonymous4 *)(&__x14__CV13s__anonymous4_1))));
    563     ((void)___destructor__F_P13s__anonymous3_autogen___1(((struct __anonymous3 *)(&__x13__CV13s__anonymous3_1))));
    564     ((void)___destructor__F_P13s__anonymous2_autogen___1(((struct __anonymous2 *)(&__x12__CV13s__anonymous2_1))));
    565     ((void)___destructor__F_P13s__anonymous1_autogen___1(((struct __anonymous1 *)(&__x11__CV13s__anonymous1_1))));
    566     ((void)___destructor__F_P13s__anonymous0_autogen___1(((struct __anonymous0 *)(&__x10__CV13s__anonymous0_1))));
    567 }
  • src/tests/.expect/32/extension.txt

    r3403534 rf04a8b81  
    8686        __extension__ int __c__i_2;
    8787    };
    88     int __i__i_2;
    89     ((void)((*((int *)(&__i__i_2)))=(__extension__ __a__i_1+__extension__ 3)) /* ?{} */);
     88    int __i__i_2 = ((int )(__extension__ __a__i_1+__extension__ 3));
    9089    ((void)__extension__ 3);
    9190    ((void)__extension__ __a__i_1);
  • src/tests/.expect/32/gccExtensions.txt

    r3403534 rf04a8b81  
    7676        ((void)((*((int *)(&(*___dst__P2sS_2).__c__i_2)))=__c__i_2) /* ?{} */);
    7777    }
    78     int __i__i_2;
    79     ((void)((*((int *)(&__i__i_2)))=__extension__ 3) /* ?{} */);
     78    int __i__i_2 = ((int )__extension__ 3);
    8079    __extension__ int __a__i_2;
    8180    __extension__ int __b__i_2;
     
    133132    }
    134133    struct s3 __x1__3ss3_2;
    135     ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    136134    struct s3 __y1__3ss3_2;
    137     ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
    138135    struct s4 {
    139136        int __i__i_2;
     
    141138    inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){
    142139        ((void)((*___dst__P3ss4_2).__i__i_2=___src__3ss4_2.__i__i_2));
    143         ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
    144         ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    145140        return ((struct s4 )___src__3ss4_2);
    146141    }
     
    158153    }
    159154    struct s4 __x2__3ss4_2;
    160     ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
    161155    struct s4 __y2__3ss4_2;
    162     ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
    163156    int __m1__A0i_2[((unsigned int )10)];
    164157    int __m2__A0A0i_2[((unsigned int )10)][((unsigned int )10)];
     
    166159    int _retVal0 = { 0 };
    167160    ((void)(_retVal0=0) /* ?{} */);
    168     ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
    169     ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
    170     ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
    171     ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    172161    return ((int )_retVal0);
    173     ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
    174     ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
    175     ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
    176     ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    177162}
Note: See TracChangeset for help on using the changeset viewer.