[cfe-commits] r118313 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/anonymous-union.cpp

Douglas Gregor dgregor at apple.com
Fri Nov 5 16:22:45 PDT 2010


Author: dgregor
Date: Fri Nov  5 18:22:45 2010
New Revision: 118313

URL: http://llvm.org/viewvc/llvm-project?rev=118313&view=rev
Log:
When searching for an instantiated declaration requires instantiation
of its parent context, be sure to update the parent-context pointer
after instantiation. Fixes two anonymous-union instantiation issues in
<rdar://problem/8635664>.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/SemaTemplate/anonymous-union.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=118313&r1=118312&r2=118313&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Nov  5 18:22:45 2010
@@ -2753,6 +2753,8 @@
         if (!Tag->isBeingDefined() &&
             RequireCompleteType(Loc, T, diag::err_incomplete_type))
           return 0;
+
+        ParentDC = Tag->getDecl();
       }
     }
 

Modified: cfe/trunk/test/SemaTemplate/anonymous-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/anonymous-union.cpp?rev=118313&r1=118312&r2=118313&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/anonymous-union.cpp (original)
+++ cfe/trunk/test/SemaTemplate/anonymous-union.cpp Fri Nov  5 18:22:45 2010
@@ -17,3 +17,24 @@
 struct A : public T0 { };
 
 void f1(T1<A> *S) { S->f0(); } // expected-note{{instantiation of member function}}
+
+namespace rdar8635664 {
+  template<typename T>
+  struct X {
+    struct inner;
+  
+    struct inner {
+      union {
+        int x;
+        float y;
+      };
+
+      typedef T type;
+    };
+  };
+
+  void test() {
+    X<int>::inner i;
+    i.x = 0;
+  }
+}





More information about the cfe-commits mailing list