]> granicus.if.org Git - clang/commitdiff
[modules] When merging the pattern of a class template definition into a prior
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Mar 2015 18:21:02 +0000 (18:21 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Mar 2015 18:21:02 +0000 (18:21 +0000)
definition, be sure to update the definition data on all declarations, not just
the canonical one, since the pattern might not be in the list of pending
definitions (if it used to be canonical itself).

One-line fix by me; reduced testcase by Daniel Jasper!

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

lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/merge-template-friend/def.h [new file with mode: 0644]
test/Modules/Inputs/merge-template-friend/friend.h [new file with mode: 0644]
test/Modules/Inputs/merge-template-friend/module.modulemap [new file with mode: 0644]
test/Modules/merge-template-friend.cpp [new file with mode: 0644]

index 565f33ecba7ec4779a0f1330c168079c90170f76..96c16ea10ee4ebc6b4c0b2712bcbe3c1830d1bc6 100644 (file)
@@ -2158,6 +2158,7 @@ void ASTDeclReader::mergeTemplatePattern(RedeclarableTemplateDecl *D,
         DClass->IsCompleteDefinition = false;
       } else {
         ExistingClass->DefinitionData = DClass->DefinitionData;
+        Reader.PendingDefinitions.insert(DClass);
       }
     }
     DClass->DefinitionData = ExistingClass->DefinitionData;
diff --git a/test/Modules/Inputs/merge-template-friend/def.h b/test/Modules/Inputs/merge-template-friend/def.h
new file mode 100644 (file)
index 0000000..c75f5f6
--- /dev/null
@@ -0,0 +1,3 @@
+namespace ns {
+template <typename T> class C {};
+}
diff --git a/test/Modules/Inputs/merge-template-friend/friend.h b/test/Modules/Inputs/merge-template-friend/friend.h
new file mode 100644 (file)
index 0000000..97fb758
--- /dev/null
@@ -0,0 +1,4 @@
+namespace ns { template <typename T> class C; };
+class A {
+  template <typename T> friend class ::ns::C;
+};
diff --git a/test/Modules/Inputs/merge-template-friend/module.modulemap b/test/Modules/Inputs/merge-template-friend/module.modulemap
new file mode 100644 (file)
index 0000000..7737ad9
--- /dev/null
@@ -0,0 +1,3 @@
+module a { header "friend.h" export * }
+module b { header "def.h" export * }
+
diff --git a/test/Modules/merge-template-friend.cpp b/test/Modules/merge-template-friend.cpp
new file mode 100644 (file)
index 0000000..8a1910d
--- /dev/null
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
+// RUN:   -emit-module -fmodule-name=a -o %t/a.pcm \
+// RUN:   %S/Inputs/merge-template-friend/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
+// RUN:   -emit-module -fmodule-name=b -o %t/b.pcm \
+// RUN:   %S/Inputs/merge-template-friend/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
+// RUN:   -I%S/Inputs/merge-template-friend \
+// RUN:   -fmodule-file=%t/a.pcm \
+// RUN:   -fmodule-file=%t/b.pcm \
+// RUN:   -verify %s
+
+#include "friend.h"
+#include "def.h"
+
+::ns::C<int> c;
+
+// expected-no-diagnostics