diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-07-01 00:21:21 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-07-01 00:21:21 +0000 |
| commit | 5a5fcd83c53ed7708d9a813363a868eba6628865 (patch) | |
| tree | 0fc7fbde66077c9379623a56cd9efc37afc77d26 | |
| parent | 8c3f9187f954b32ae0e737b7c05d9af3e71434d0 (diff) | |
| download | bcm5719-llvm-5a5fcd83c53ed7708d9a813363a868eba6628865.tar.gz bcm5719-llvm-5a5fcd83c53ed7708d9a813363a868eba6628865.zip | |
Be a bit more careful with undefined CXXRecordDecls. Fixes
rdar://problem/8124080 and PR7118.
llvm-svn: 107358
| -rw-r--r-- | clang/lib/Sema/JumpDiagnostics.cpp | 12 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/crash-8124080.cpp | 21 |
3 files changed, 29 insertions, 6 deletions
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp index 47dfbfbdc8a..3431ac61188 100644 --- a/clang/lib/Sema/JumpDiagnostics.cpp +++ b/clang/lib/Sema/JumpDiagnostics.cpp @@ -131,11 +131,13 @@ static std::pair<unsigned,unsigned> InDiag = diag::note_protected_by_variable_init; CanQualType T = VD->getType()->getCanonicalTypeUnqualified(); - while (CanQual<ArrayType> AT = T->getAs<ArrayType>()) - T = AT->getElementType(); - if (CanQual<RecordType> RT = T->getAs<RecordType>()) - if (!cast<CXXRecordDecl>(RT->getDecl())->hasTrivialDestructor()) - OutDiag = diag::note_exits_dtor; + if (!T->isDependentType()) { + while (CanQual<ArrayType> AT = T->getAs<ArrayType>()) + T = AT->getElementType(); + if (CanQual<RecordType> RT = T->getAs<RecordType>()) + if (!cast<CXXRecordDecl>(RT->getDecl())->hasTrivialDestructor()) + OutDiag = diag::note_exits_dtor; + } } return std::make_pair(InDiag, OutDiag); diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 906bce2fe34..4337e906fe4 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1127,7 +1127,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // If this isn't a C++ class, we aren't allowed to look into base // classes, we're done. CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx); - if (!LookupRec) + if (!LookupRec || !LookupRec->getDefinition()) return false; // If we're performing qualified name lookup into a dependent class, diff --git a/clang/test/SemaCXX/crash-8124080.cpp b/clang/test/SemaCXX/crash-8124080.cpp new file mode 100644 index 00000000000..78a031561a5 --- /dev/null +++ b/clang/test/SemaCXX/crash-8124080.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// <rdar://problem/8124080> +template<typename _Alloc> class allocator; +template<class _CharT> struct char_traits; +template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > +class basic_string; +template<typename _CharT, typename _Traits, typename _Alloc> +const typename basic_string<_CharT, _Traits, _Alloc>::size_type +basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_max_size // expected-error{{no member named '_Rep' in 'basic_string<_CharT, _Traits, _Alloc>'}} + = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4; + +// PR7118 +template<typename T> +class Foo { + class Bar; + void f() { + Bar i; + } +}; |

