From 5c49e1a34925555e28ff8b4148e3446bdeb91d6e Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Mon, 28 Dec 2015 19:40:14 +0000 Subject: Do not crash if class is defined in wrong scope. This patch fixes PR16677. The latter represents the case when due to misprinted character class definition occurs in the scope of template arguments. Base class of this class depends on the template parameter in the same scope and cannot be resolved, it causes crash. Right behavior is to make semantic processing even if the definition is wrong, as the code that emits appropriate message is called after the processing. llvm-svn: 256511 --- clang/lib/Sema/SemaDeclCXX.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index cdfdc37f5e8..9cd3002dd8d 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -5626,7 +5626,9 @@ bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject( /// having a particular direct or virtual base class. bool SpecialMemberDeletionInfo::shouldDeleteForBase(CXXBaseSpecifier *Base) { CXXRecordDecl *BaseClass = Base->getType()->getAsCXXRecordDecl(); - return shouldDeleteForClassSubobject(BaseClass, Base, 0); + // If program is correct, BaseClass cannot be null, but if it is, the error + // must be reported elsewhere. + return BaseClass && shouldDeleteForClassSubobject(BaseClass, Base, 0); } /// Check whether we should delete a special member function due to the class -- cgit v1.2.3