[llvm-branch-commits] [cfe-branch] r286923 - Merging rr285370:
Richard Trieu via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 14 17:16:26 PST 2016
Author: rtrieu
Date: Mon Nov 14 19:16:26 2016
New Revision: 286923
URL: http://llvm.org/viewvc/llvm-project?rev=286923&view=rev
Log:
Merging rr285370:
------------------------------------------------------------------------
r285370 | rtrieu | 2016-10-27 17:15:24 -0700 (Thu, 27 Oct 2016) | 10 lines
Fix a crash on invalid code.
The diagnostic was attempting to access the QualType of a TypeDecl by calling
TypeDecl::getTypeForDecl. However, the Type pointer stored there is lazily
loaded by functions in ASTContext. In most cases, the pointer is loaded and
this does not cause a problem. However, when more that 50 or so unknown types
are seen beforehand, this causes the Type to not be loaded, passing a null
Type to the diagnostics, leading to the crash. Using
ASTContext::getTypeDeclType will give a proper QualType for all cases.
------------------------------------------------------------------------
Modified:
cfe/branches/release_39/lib/Sema/SemaCXXScopeSpec.cpp
cfe/branches/release_39/test/SemaCXX/nested-name-spec.cpp
Modified: cfe/branches/release_39/lib/Sema/SemaCXXScopeSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Sema/SemaCXXScopeSpec.cpp?rev=286923&r1=286922&r2=286923&view=diff
==============================================================================
--- cfe/branches/release_39/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/branches/release_39/lib/Sema/SemaCXXScopeSpec.cpp Mon Nov 14 19:16:26 2016
@@ -806,7 +806,7 @@ bool Sema::BuildCXXNestedNameSpecifier(S
if (!Found.empty()) {
if (TypeDecl *TD = Found.getAsSingle<TypeDecl>())
Diag(IdentifierLoc, diag::err_expected_class_or_namespace)
- << QualType(TD->getTypeForDecl(), 0) << getLangOpts().CPlusPlus;
+ << Context.getTypeDeclType(TD) << getLangOpts().CPlusPlus;
else {
Diag(IdentifierLoc, diag::err_expected_class_or_namespace)
<< &Identifier << getLangOpts().CPlusPlus;
Modified: cfe/branches/release_39/test/SemaCXX/nested-name-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/SemaCXX/nested-name-spec.cpp?rev=286923&r1=286922&r2=286923&view=diff
==============================================================================
--- cfe/branches/release_39/test/SemaCXX/nested-name-spec.cpp (original)
+++ cfe/branches/release_39/test/SemaCXX/nested-name-spec.cpp Mon Nov 14 19:16:26 2016
@@ -435,3 +435,21 @@ namespace PR16951 {
// expected-error{{no member named 'X2' in 'PR16951::enumerator_2'}}
}
+
+namespace PR30619 {
+c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d;
+// expected-error at -1 16{{unknown type name 'c'}}
+c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d;
+// expected-error at -1 16{{unknown type name 'c'}}
+c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d;
+// expected-error at -1 16{{unknown type name 'c'}}
+c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d; c d;
+// expected-error at -1 16{{unknown type name 'c'}}
+namespace A {
+class B {
+ typedef C D; // expected-error{{unknown type name 'C'}}
+ A::D::F;
+ // expected-error at -1{{'D' (aka 'int') is not a class, namespace, or enumeration}}
+};
+}
+}
More information about the llvm-branch-commits
mailing list