[PATCH] PR16225 - Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope"
Serge Pavlov
sepavloff at gmail.com
Wed Jun 5 06:16:22 PDT 2013
sepavloff added you to the CC list for the revision "PR16225 - Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope"".
This patch fixes PR16225.
If template declaration is invalid, it may be uninstantiated.
Could someone please review?
Thank you.
http://llvm-reviews.chandlerc.com/D920
Files:
lib/Parse/ParseDeclCXX.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaCXX/PR16225.cpp
test/SemaCXX/class.cpp
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -917,8 +917,10 @@
<< Id;
}
- if (!Template)
+ if (!Template) {
+ SkipUntil(tok::greater, /*StopAtSemi=*/true, /*DontConsume=*/false);
return true;
+ }
// Form the template name
UnqualifiedId TemplateName;
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3550,6 +3550,9 @@
return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
}
+ if (D->isInvalidDecl())
+ return 0;
+
// If we didn't find the decl, then we must have a label decl that hasn't
// been found yet. Lazily instantiate it and return it now.
assert(isa<LabelDecl>(D));
Index: test/SemaCXX/PR16225.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/PR16225.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify %s
+
+template <typename T> void f();
+
+template<typename C> void g(C*) {
+ struct LocalStruct : UnkonwnBase<Mumble, C> { }; // expected-error {{unknown template name 'UnkonwnBase'}}
+ f<LocalStruct>(); // expected-warning {{template argument uses local type 'LocalStruct'}}
+}
+
+struct S;
+void h() {
+ g<S>(0); // expected-note {{in instantiation of function template specialization 'g<S>'}}
+}
Index: test/SemaCXX/class.cpp
===================================================================
--- test/SemaCXX/class.cpp
+++ test/SemaCXX/class.cpp
@@ -128,10 +128,7 @@
namespace pr6629 {
// TODO: most of these errors are spurious
template<class T1, class T2> struct foo :
- bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}} \
- // BOGUS expected-error {{expected '{' after base class list}} \
- // BOGUS expected-error {{expected ';' after struct}} \
- // BOGUS expected-error {{expected unqualified-id}}
+ bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}}
{ };
template<> struct foo<unknown,unknown> { // expected-error {{undeclared identifier 'unknown'}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D920.1.patch
Type: text/x-patch
Size: 2340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130605/007414fb/attachment.bin>
More information about the cfe-commits
mailing list