]> granicus.if.org Git - clang/commitdiff
Add redecls into their lexical DeclContext: this is what they assert on, and the...
authorAxel Naumann <Axel.Naumann@cern.ch>
Tue, 2 Oct 2012 13:06:13 +0000 (13:06 +0000)
committerAxel Naumann <Axel.Naumann@cern.ch>
Tue, 2 Oct 2012 13:06:13 +0000 (13:06 +0000)
This is especially relevant for templatedDecls that might be injected (and thus have their DeclContext set to) somewhere completely different.

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

lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/templates-top.h

index e770c0651990e02da781c7b7b315985505dd5f00..4f2da6bc518bc0ae4451967ee655a588eea57d90 100644 (file)
@@ -1775,7 +1775,7 @@ ASTDeclReader::FindExistingResult::~FindExistingResult() {
   if (!AddResult || Existing)
     return;
   
-  DeclContext *DC = New->getDeclContext()->getRedeclContext();
+  DeclContext *DC = New->getLexicalDeclContext();
   if (DC->isTranslationUnit() && Reader.SemaObj) {
     if (Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName()))
       Reader.RedeclsAddedToAST.insert(New);
index 80ecf23ea49c48aadd3aa5eb47b659e21d902693..5985ee8820d698e43aa60612d41397edd1068935 100644 (file)
@@ -4,3 +4,14 @@ template<typename T> class List {
 public:
   void push_back(T);
 };
+
+namespace A {
+  class Y {
+    template <typename T> friend class WhereAmI;
+  };
+}
+
+template <typename T> class A::WhereAmI {
+public:
+  static void func() {}
+};