]> granicus.if.org Git - clang/commitdiff
Add some more tests for instantiation of declaration references. Also,
authorDouglas Gregor <dgregor@apple.com>
Wed, 27 May 2009 17:30:49 +0000 (17:30 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 27 May 2009 17:30:49 +0000 (17:30 +0000)
improve some error recovery with explicit template instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72484 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
lib/Sema/SemaTemplate.cpp
test/SemaTemplate/instantiate-declref.cpp

index 5e09851770b2298bc088369aa3bb2bba4e65a810..d592cf6178b428f023846f02385cc0814a064211 100644 (file)
@@ -3358,6 +3358,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
     if (PrevDecl == 0) {
       Diag(NameLoc, diag::err_not_tag_in_scope) << Name << SS.getRange();
       Name = 0;
+      Invalid = true;
       goto CreateNewDecl;
     }
   } else if (Name) {
@@ -3629,7 +3630,8 @@ CreateNewDecl:
   New->setLexicalDeclContext(CurContext);
 
   // Set the access specifier.
-  SetMemberAccessSpecifier(New, PrevDecl, AS);
+  if (!Invalid)
+    SetMemberAccessSpecifier(New, PrevDecl, AS);
 
   if (TK == TK_Definition)
     New->startDefinition();
index c533789458fdab17c250ec31aaec0adedbb1555f..97eca48b9f60c4ed258ec3f5746a477ee85d341a 100644 (file)
@@ -2369,6 +2369,9 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc,
     return true;
   }
 
+  if (Tag->isInvalidDecl())
+    return true;
+
   CXXRecordDecl *Record = cast<CXXRecordDecl>(Tag);
   CXXRecordDecl *Pattern = Record->getInstantiatedFromMemberClass();
   if (!Pattern) {
index cceaed00e69da7ad1e17f92e8c313c3c433f1775..3b6db38617b037cb9fad0bd46a3d6609082c33c2 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only %s
+// RUN: clang-cc -fsyntax-only -verify %s
 
 namespace N {
   struct Outer {
@@ -10,12 +10,22 @@ namespace N {
 
           static enum K1 { K1Val = sizeof(T) } Kind1;
           static enum { K2Val = sizeof(T)*2 } Kind2;
+          enum { K3Val = sizeof(T)*2 } Kind3;
 
           void foo() {
             K1 k1 = K1Val;
             Kind1 = K1Val;
             Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val;
+            Kind3 = K3Val;
           }
+
+          struct UeberInner {
+            void bar() {
+              K1 k1 = K1Val;
+              Kind1 = K1Val;
+              Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val;
+            }
+          };
         };
       };
     };
@@ -24,3 +34,4 @@ namespace N {
 
 typedef int INT;
 template struct N::Outer::Inner::InnerTemplate<INT>::VeryInner;
+template struct N::Outer::Inner::InnerTemplate<INT>::UeberInner; // expected-error{{'UeberInner' does not name a tag member}}