diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-09 16:55:27 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-09 16:55:27 +0000 |
| commit | d55889a6551f6a8efddeaa781330f7f1368b2fcb (patch) | |
| tree | 4a17235bc1d5c2f09f27ca769c66cb101899b339 /clang/test/Modules | |
| parent | 1b18a5ec2863d3345073576227fb67cbb6a4f13a (diff) | |
| download | bcm5719-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/Modules')
| -rw-r--r-- | clang/test/Modules/Inputs/cxx-templates-a.h | 6 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/cxx-templates-b.h | 6 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/templates-left.h | 2 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/templates-right.h | 2 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/templates-top.h | 4 | ||||
| -rw-r--r-- | clang/test/Modules/cxx-templates.cpp | 8 | ||||
| -rw-r--r-- | clang/test/Modules/templates.mm | 5 |
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}} |

