[cfe-commits] r72484 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp test/SemaTemplate/instantiate-declref.cpp
Douglas Gregor
dgregor at apple.com
Wed May 27 10:31:13 PDT 2009
Author: dgregor
Date: Wed May 27 12:30:49 2009
New Revision: 72484
URL: http://llvm.org/viewvc/llvm-project?rev=72484&view=rev
Log:
Add some more tests for instantiation of declaration references. Also,
improve some error recovery with explicit template instantiation.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/instantiate-declref.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=72484&r1=72483&r2=72484&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 27 12:30:49 2009
@@ -3358,6 +3358,7 @@
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 @@
New->setLexicalDeclContext(CurContext);
// Set the access specifier.
- SetMemberAccessSpecifier(New, PrevDecl, AS);
+ if (!Invalid)
+ SetMemberAccessSpecifier(New, PrevDecl, AS);
if (TK == TK_Definition)
New->startDefinition();
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=72484&r1=72483&r2=72484&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed May 27 12:30:49 2009
@@ -2369,6 +2369,9 @@
return true;
}
+ if (Tag->isInvalidDecl())
+ return true;
+
CXXRecordDecl *Record = cast<CXXRecordDecl>(Tag);
CXXRecordDecl *Pattern = Record->getInstantiatedFromMemberClass();
if (!Pattern) {
Modified: cfe/trunk/test/SemaTemplate/instantiate-declref.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-declref.cpp?rev=72484&r1=72483&r2=72484&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-declref.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-declref.cpp Wed May 27 12:30:49 2009
@@ -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 @@
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 @@
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}}
More information about the cfe-commits
mailing list