diff options
author | Aleksei Sidorin <a.sidorin@samsung.com> | 2017-11-21 16:08:41 +0000 |
---|---|---|
committer | Aleksei Sidorin <a.sidorin@samsung.com> | 2017-11-21 16:08:41 +0000 |
commit | cddb621fac41e4e9241138b34d883f54d9c5f475 (patch) | |
tree | 5a233b8fb3c07c1389a1f23369400805175108bc /test/ASTMerge | |
parent | 20f8dd07c79edfee3f1ba0d27646504353a0ac07 (diff) |
[ASTImporter] Support new AST nodes:
* UnresolvedUsingType
* EmptyDecl
* NamespaceAliasDecl
* UsingDecl
* UsingShadowDecl
* UsingDirectiveDecl
* UnresolvedUsingValueDecl
* UnresolvedUsingTypenameDecl
Refactor error handling in ImportTemplateArgumentLoc() method.
Add a test for inline namespaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/ASTMerge')
-rw-r--r-- | test/ASTMerge/namespace/Inputs/namespace1.cpp | 10 | ||||
-rw-r--r-- | test/ASTMerge/namespace/Inputs/namespace2.cpp | 43 | ||||
-rw-r--r-- | test/ASTMerge/namespace/test.cpp | 17 |
3 files changed, 67 insertions, 3 deletions
diff --git a/test/ASTMerge/namespace/Inputs/namespace1.cpp b/test/ASTMerge/namespace/Inputs/namespace1.cpp index 1ff84f3111..4a539523aa 100644 --- a/test/ASTMerge/namespace/Inputs/namespace1.cpp +++ b/test/ASTMerge/namespace/Inputs/namespace1.cpp @@ -15,3 +15,13 @@ namespace N2 { namespace N3 { extern float z; } + +namespace AliasWithSameName = N3; + +namespace TestUnresolvedTypenameAndValueDecls { +template <class T> class Base { +public: + typedef T foo; + void bar(); +}; +} diff --git a/test/ASTMerge/namespace/Inputs/namespace2.cpp b/test/ASTMerge/namespace/Inputs/namespace2.cpp index 80429f700b..f65057d1ca 100644 --- a/test/ASTMerge/namespace/Inputs/namespace2.cpp +++ b/test/ASTMerge/namespace/Inputs/namespace2.cpp @@ -15,3 +15,46 @@ namespace N2 { namespace N3 { extern double z; } + +namespace Enclosing { +namespace Nested { + const int z = 4; +} +} + +namespace ContainsInline { + inline namespace Inline { + const int z = 10; + } +} + +namespace TestAliasName = Enclosing::Nested; +// NOTE: There is no warning on this alias. +namespace AliasWithSameName = Enclosing::Nested; + +namespace TestUsingDecls { + +namespace A { +void foo(); +} +namespace B { +using A::foo; // <- a UsingDecl creating a UsingShadow +} + +}// end namespace TestUsingDecls + +namespace TestUnresolvedTypenameAndValueDecls { + +template <class T> class Base; +template <class T> class Derived : public Base<T> { +public: + using typename Base<T>::foo; + using Base<T>::bar; + typedef typename Derived::foo NewUnresolvedUsingType; +}; + +} // end namespace TestUnresolvedTypenameAndValueDecls + +namespace TestUsingNamespace { + using namespace Enclosing; +} diff --git a/test/ASTMerge/namespace/test.cpp b/test/ASTMerge/namespace/test.cpp index 8cc0fa2a6d..f1796c03b0 100644 --- a/test/ASTMerge/namespace/test.cpp +++ b/test/ASTMerge/namespace/test.cpp @@ -1,6 +1,17 @@ -// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/namespace1.cpp -// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/namespace2.cpp -// RUN: not %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.1.ast %S/Inputs/namespace1.cpp +// RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.2.ast %S/Inputs/namespace2.cpp +// RUN: not %clang_cc1 -std=c++1z -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s + +static_assert(TestAliasName::z == 4); +static_assert(ContainsInline::z == 10); + +void testImport() { + typedef TestUnresolvedTypenameAndValueDecls::Derived<int> Imported; + Imported a; // Successfull instantiation + static_assert(sizeof(Imported::foo) == sizeof(int)); + static_assert(sizeof(TestUnresolvedTypenameAndValueDecls::Derived<double>::NewUnresolvedUsingType) == sizeof(double)); +} + // CHECK: namespace2.cpp:16:17: error: external variable 'z' declared with incompatible types in different translation units ('double' vs. 'float') // CHECK: namespace1.cpp:16:16: note: declared here with type 'float' |