diff options
author | John McCall <rjmccall@apple.com> | 2010-08-17 07:23:57 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-08-17 07:23:57 +0000 |
commit | 572fc62b52b5b113cbaf528bd3ec00fcde19a46e (patch) | |
tree | e1a3be080486783193f960a14812154945af8f3a /lib | |
parent | 727d93ef49e18147149354fadd10e86b13bc4ab0 (diff) |
Don't try to initialize a reference with a constructed temporary if either
of the classes is invalid. A class is invalid if a base is invalid.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111227 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 1d0b4a9450..3f59fb71d0 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -483,8 +483,10 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, // defined class. if (RequireCompleteType(BaseLoc, BaseType, PDiag(diag::err_incomplete_base_class) - << SpecifierRange)) + << SpecifierRange)) { + Class->setInvalidDecl(); return 0; + } // If the base class is polymorphic or isn't empty, the new one is/isn't, too. RecordDecl *BaseDecl = BaseType->getAs<RecordType>()->getDecl(); @@ -503,6 +505,9 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, } SetClassDeclAttributesFromBase(Class, CXXBaseDecl, Virtual); + + if (BaseDecl->isInvalidDecl()) + Class->setInvalidDecl(); // Create the base specifier. return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual, diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index e1fcab0c40..13ba8ee5f9 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -2306,6 +2306,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, // The type we're converting to is a class type. Enumerate its constructors // to see if there is a suitable conversion. CXXRecordDecl *T1RecordDecl = cast<CXXRecordDecl>(T1RecordType->getDecl()); + DeclContext::lookup_iterator Con, ConEnd; for (llvm::tie(Con, ConEnd) = S.LookupConstructors(T1RecordDecl); Con != ConEnd; ++Con) { @@ -2333,6 +2334,8 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, } } } + if (T1RecordType && T1RecordType->getDecl()->isInvalidDecl()) + return OR_No_Viable_Function; const RecordType *T2RecordType = 0; if ((T2RecordType = T2->getAs<RecordType>()) && @@ -2380,6 +2383,8 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, } } } + if (T2RecordType && T2RecordType->getDecl()->isInvalidDecl()) + return OR_No_Viable_Function; SourceLocation DeclLoc = Initializer->getLocStart(); |