]> granicus.if.org Git - clang/commitdiff
When searching for an instantiated declaration requires instantiation
authorDouglas Gregor <dgregor@apple.com>
Fri, 5 Nov 2010 23:22:45 +0000 (23:22 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 5 Nov 2010 23:22:45 +0000 (23:22 +0000)
of its parent context, be sure to update the parent-context pointer
after instantiation. Fixes two anonymous-union instantiation issues in
<rdar://problem/8635664>.

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

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaTemplate/anonymous-union.cpp

index 6e352e71ef6531aa250b4aad940a24931b99597d..a594e678d6ce6c02b5597fc83aee5c4018c6e659 100644 (file)
@@ -2753,6 +2753,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
         if (!Tag->isBeingDefined() &&
             RequireCompleteType(Loc, T, diag::err_incomplete_type))
           return 0;
+
+        ParentDC = Tag->getDecl();
       }
     }
 
index 59d1f25a4fd2a564bb2f02fcd06433c8f91eac57..97ecd6e60cca1510d0b00c74c3d8503ed7845cfc 100644 (file)
@@ -17,3 +17,24 @@ struct T1 : public T0, public T {
 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;
+  }
+}