Changeset 235114f


Ignore:
Timestamp:
Mar 13, 2017, 4:50:15 PM (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, resolv-new, with_gc
Children:
88d1066
Parents:
0b465a5
Message:

fix generated function hiding to allow hiding default constructor

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r0b465a5 r235114f  
    119119                                FunctionDecl * decl;
    120120                                bool isUserDefinedFunc; // properties for this particular decl
    121                                 bool isDefaultFunc;
     121                                bool isDefaultCtor;
     122                                bool isDtor;
    122123                                bool isCopyFunc;
    123124                        };
    124125                        // properties for this type
    125                         bool userDefinedFunc = false; // any user defined function found
    126                         bool userDefinedDefaultFunc = false; // user defined default ctor found
    127                         bool userDefinedCopyFunc = false; // user defined copy ctor found
     126                        bool userDefinedFunc = false; // any user-defined function found
     127                        bool userDefinedCtor = false; // any user-defined constructor found
     128                        bool userDefinedDtor = false; // any user-defined destructor found
     129                        bool userDefinedCopyFunc = false; // user-defined copy ctor found
    128130                        std::list< DeclBall > decls;
    129131
     
    132134                        ValueType & operator+=( FunctionDecl * function ) {
    133135                                bool isUserDefinedFunc = ! LinkageSpec::isOverridable( function->get_linkage() );
    134                                 bool isDefaultFunc = function->get_functionType()->get_parameters().size() == 1;
     136                                bool isDefaultCtor = InitTweak::isDefaultConstructor( function );
     137                                bool isDtor = InitTweak::isDestructor( function );
    135138                                bool isCopyFunc = InitTweak::isCopyFunction( function, function->get_name() );
    136                                 decls.push_back( DeclBall{ function, isUserDefinedFunc, isDefaultFunc, isCopyFunc } );
     139                                decls.push_back( DeclBall{ function, isUserDefinedFunc, isDefaultCtor, isDtor, isCopyFunc } );
    137140                                userDefinedFunc = userDefinedFunc || isUserDefinedFunc;
    138                                 userDefinedDefaultFunc = userDefinedDefaultFunc || (isUserDefinedFunc && isDefaultFunc);
     141                                userDefinedCtor = userDefinedCtor || (isUserDefinedFunc && InitTweak::isConstructor( function->get_name() ) );
     142                                userDefinedDtor = userDefinedDtor || (isUserDefinedFunc && isDtor);
    139143                                userDefinedCopyFunc = userDefinedCopyFunc || (isUserDefinedFunc && isCopyFunc);
    140144                                return *this;
     
    163167                // a default ctor, then the generated default ctor should never be seen, likewise for copy ctor
    164168                // and dtor. If the user defines any ctor/dtor, then no generated field ctors should be seen.
     169                // If the user defines any ctor then the generated default ctor should not be seen.
    165170                for ( std::pair< const std::string, ValueType > & pair : funcMap ) {
    166171                        ValueType & val = pair.second;
    167172                        for ( ValueType::DeclBall ball : val.decls ) {
    168                                 if ( ! val.userDefinedFunc || ball.isUserDefinedFunc || (! val.userDefinedDefaultFunc && ball.isDefaultFunc) || (! val.userDefinedCopyFunc && ball.isCopyFunc) ) {
     173                                if ( ! val.userDefinedFunc || ball.isUserDefinedFunc || (! val.userDefinedCtor && ball.isDefaultCtor) || (! val.userDefinedCopyFunc && ball.isCopyFunc) || (! val.userDefinedDtor && ball.isDtor) ) {
    169174                                        // decl conforms to the rules described above, so it should be seen by the requester
    170175                                        out.push_back( ball.decl );
  • src/tests/memberCtors.c

    r0b465a5 r235114f  
    3030  WrappedInt x, y, z;
    3131};
     32
     33void ?{}(A * a) {
     34  // currently must define default ctor, since there's no "= default" syntax
     35}
    3236
    3337void ?{}(A * a, int x) {
Note: See TracChangeset for help on using the changeset viewer.