r176727 - <rdar://problem/13094134> Don't try to wire up typedef names for invalid anonymous tag declarations encountered during template instantiation.

Douglas Gregor dgregor at apple.com
Fri Mar 8 14:15:15 PST 2013


Author: dgregor
Date: Fri Mar  8 16:15:15 2013
New Revision: 176727

URL: http://llvm.org/viewvc/llvm-project?rev=176727&view=rev
Log:
<rdar://problem/13094134> Don't try to wire up typedef names for invalid anonymous tag declarations encountered during template instantiation.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/SemaTemplate/instantiate-type.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=176727&r1=176726&r2=176727&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Mar  8 16:15:15 2013
@@ -229,7 +229,7 @@ Decl *TemplateDeclInstantiator::Instanti
   // tag decl, re-establish that relationship for the new typedef.
   if (const TagType *oldTagType = D->getUnderlyingType()->getAs<TagType>()) {
     TagDecl *oldTag = oldTagType->getDecl();
-    if (oldTag->getTypedefNameForAnonDecl() == D) {
+    if (oldTag->getTypedefNameForAnonDecl() == D && !Invalid) {
       TagDecl *newTag = DI->getType()->castAs<TagType>()->getDecl();
       assert(!newTag->getIdentifier() && !newTag->getTypedefNameForAnonDecl());
       newTag->setTypedefNameForAnonDecl(Typedef);

Modified: cfe/trunk/test/SemaTemplate/instantiate-type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-type.cpp?rev=176727&r1=176726&r2=176727&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-type.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-type.cpp Fri Mar  8 16:15:15 2013
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 int* f(int);
 float *f(...);
@@ -15,3 +15,14 @@ X<int>::typeof_type &iptr1 = iptr0;
 
 X<int>::typeof_expr &iptr2 = iptr0;
 X<float*>::typeof_expr &fptr1 = fptr0;
+
+namespace rdar13094134 {
+  template <class>
+  class X {
+    typedef struct {
+      Y *y; // expected-error{{unknown type name 'Y'}}
+    } Y; 
+  };
+
+  X<int> xi;
+}





More information about the cfe-commits mailing list