summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-09-09 16:55:27 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-09-09 16:55:27 +0000
commitd55889a6551f6a8efddeaa781330f7f1368b2fcb (patch)
tree4a17235bc1d5c2f09f27ca769c66cb101899b339 /clang/test
parent1b18a5ec2863d3345073576227fb67cbb6a4f13a (diff)
downloadbcm5719-llvm-d55889a6551f6a8efddeaa781330f7f1368b2fcb.tar.gz
bcm5719-llvm-d55889a6551f6a8efddeaa781330f7f1368b2fcb.zip
C++ modules: if a class is defined in multiple modules (for instance, because
it is an implicit instantiation of a class template specialization), pick the first-loaded definition to be the canonical definition, and merge all other definitions into it. This is still rather incomplete -- we need to extend every form of declaration that can appear within a CXXRecordDecl to be redeclarable if it came from an AST file (this includes fields, enumerators, ...). llvm-svn: 190315
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Modules/Inputs/cxx-templates-a.h6
-rw-r--r--clang/test/Modules/Inputs/cxx-templates-b.h6
-rw-r--r--clang/test/Modules/Inputs/templates-left.h2
-rw-r--r--clang/test/Modules/Inputs/templates-right.h2
-rw-r--r--clang/test/Modules/Inputs/templates-top.h4
-rw-r--r--clang/test/Modules/cxx-templates.cpp8
-rw-r--r--clang/test/Modules/templates.mm5
7 files changed, 33 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/cxx-templates-a.h b/clang/test/Modules/Inputs/cxx-templates-a.h
index dbf12dacbae..37e3426fc0b 100644
--- a/clang/test/Modules/Inputs/cxx-templates-a.h
+++ b/clang/test/Modules/Inputs/cxx-templates-a.h
@@ -24,3 +24,9 @@ template<typename T> void PerformDelayedLookup(T &t) {
template<typename T> void PerformDelayedLookupInDefaultArgument(T &t, int a = (FoundByADL(T()), 0)) {}
template<typename T> struct RedeclaredAsFriend {};
+
+void use_some_template_a() {
+ SomeTemplate<char[2]> a;
+ SomeTemplate<char[1]> b, c;
+ b = c;
+}
diff --git a/clang/test/Modules/Inputs/cxx-templates-b.h b/clang/test/Modules/Inputs/cxx-templates-b.h
index 9bc76d5bbae..c495074a93f 100644
--- a/clang/test/Modules/Inputs/cxx-templates-b.h
+++ b/clang/test/Modules/Inputs/cxx-templates-b.h
@@ -35,6 +35,12 @@ struct RedeclareTemplateAsFriend {
friend struct RedeclaredAsFriend;
};
+void use_some_template_b() {
+ SomeTemplate<char[1]> a;
+ SomeTemplate<char[2]> b, c;
+ b = c;
+}
+
@import cxx_templates_a;
template<typename T> void UseDefinedInBImplIndirectly(T &v) {
PerformDelayedLookup(v);
diff --git a/clang/test/Modules/Inputs/templates-left.h b/clang/test/Modules/Inputs/templates-left.h
index 7451420c748..7c9be8c6514 100644
--- a/clang/test/Modules/Inputs/templates-left.h
+++ b/clang/test/Modules/Inputs/templates-left.h
@@ -27,3 +27,5 @@ void triggerPendingInstantiation() {
}
void redeclDefinitionEmit(){}
+
+typedef Outer<int>::Inner OuterIntInner_left;
diff --git a/clang/test/Modules/Inputs/templates-right.h b/clang/test/Modules/Inputs/templates-right.h
index d3524d34769..bacaa49b60c 100644
--- a/clang/test/Modules/Inputs/templates-right.h
+++ b/clang/test/Modules/Inputs/templates-right.h
@@ -25,3 +25,5 @@ void triggerPendingInstantiationToo() {
}
void redeclDefinitionEmit(){}
+
+typedef Outer<int>::Inner OuterIntInner_right;
diff --git a/clang/test/Modules/Inputs/templates-top.h b/clang/test/Modules/Inputs/templates-top.h
index 5985ee8820d..b5d0b6bda13 100644
--- a/clang/test/Modules/Inputs/templates-top.h
+++ b/clang/test/Modules/Inputs/templates-top.h
@@ -15,3 +15,7 @@ template <typename T> class A::WhereAmI {
public:
static void func() {}
};
+
+template<typename T> struct Outer {
+ struct Inner {};
+};
diff --git a/clang/test/Modules/cxx-templates.cpp b/clang/test/Modules/cxx-templates.cpp
index 9e6cd17828e..f34a2bdaa71 100644
--- a/clang/test/Modules/cxx-templates.cpp
+++ b/clang/test/Modules/cxx-templates.cpp
@@ -82,6 +82,14 @@ typedef SomeTemplate<int&> SomeTemplateIntRef;
SomeTemplate<char*> some_template_char_ptr;
SomeTemplate<char&> some_template_char_ref;
+void testImplicitSpecialMembers(SomeTemplate<char[1]> &a,
+ const SomeTemplate<char[1]> &b,
+ SomeTemplate<char[2]> &c,
+ const SomeTemplate<char[2]> &d) {
+ a = b;
+ c = d;
+}
+
// CHECK-GLOBAL: DeclarationName 'f'
// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
// CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f'
diff --git a/clang/test/Modules/templates.mm b/clang/test/Modules/templates.mm
index 1fef967e400..08b216646c3 100644
--- a/clang/test/Modules/templates.mm
+++ b/clang/test/Modules/templates.mm
@@ -32,5 +32,10 @@ void testRedeclDefinition() {
redeclDefinitionEmit();
}
+// These three are all the same type.
+typedef OuterIntInner_left OuterIntInner;
+typedef OuterIntInner_right OuterIntInner;
+typedef Outer<int>::Inner OuterIntInner;
+
// CHECK: call {{.*pendingInstantiation}}
// CHECK: call {{.*redeclDefinitionEmit}}
OpenPOWER on IntegriCloud