[PATCH] D34383: [Sema] PR32953: Fix hard crash of implicit instantiation of undefined template preceeded by scoped variable

don hinton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 19 21:37:32 PDT 2017


hintonda created this revision.

Reset ScopeSpec when parsing class, struct, etc..  Fixes PR32953.


https://reviews.llvm.org/D34383

Files:
  lib/Parse/ParseDecl.cpp
  test/SemaTemplate/instantiate-complete.cpp


Index: test/SemaTemplate/instantiate-complete.cpp
===================================================================
--- test/SemaTemplate/instantiate-complete.cpp
+++ test/SemaTemplate/instantiate-complete.cpp
@@ -134,6 +134,14 @@
   template class B<int>; // expected-note {{in instantiation}}
 }
 
+namespace PR32953 {
+  struct bar {};
+  template <typename A> struct Temp; // expected-note {{template is declared here}}
+  PR32953::bar struct Temp<int>::foo(); // expected-error {{implicit instantiation of undefined template 'PR32953::Temp<int>'}} \
+                                         expected-error {{cannot combine with previous 'type-name' declaration specifier}} \
+                                         expected-error {{expected unqualified-id}}
+}
+
 namespace PR8425 {
   template <typename T>
   class BaseT {};
Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -3581,6 +3581,8 @@
       tok::TokenKind Kind = Tok.getKind();
       ConsumeToken();
 
+      DS.getTypeSpecScope() = CXXScopeSpec();
+
       // These are attributes following class specifiers.
       // To produce better diagnostic, we parse them when
       // parsing class specifier.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34383.103145.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170620/7a626cab/attachment.bin>


More information about the cfe-commits mailing list