diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-13 18:18:50 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-13 18:18:50 +0000 |
commit | dd9459f8869f66409f7ea429053b453e33f6499c (patch) | |
tree | a2da98d24ea77e1e6e0c76f8f793ab8fc1a5e072 /test/PCH | |
parent | f758bc7125d59bca12bb6c5f1d3c9025f395710e (diff) | |
download | clang-dd9459f8869f66409f7ea429053b453e33f6499c.tar.gz clang-dd9459f8869f66409f7ea429053b453e33f6499c.tar.bz2 clang-dd9459f8869f66409f7ea429053b453e33f6499c.tar.xz |
Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3:
When a local extern declaration redeclares some other entity, the type of that
entity is merged with the prior type if the prior declaration is visible (in C)
or is declared in the same scope (in C++).
- Make LookupRedeclarationWithLinkage actually work in C++, use it in the right
set of cases, and make it track whether it found a shadowed declaration.
- Track whether we found a declaration in the same scope (for C++) including
across serialization and template instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188307 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/cxx-templates.cpp | 16 | ||||
-rw-r--r-- | test/PCH/cxx-templates.h | 15 |
2 files changed, 25 insertions, 6 deletions
diff --git a/test/PCH/cxx-templates.cpp b/test/PCH/cxx-templates.cpp index 763838b3bf..e5ddd86e38 100644 --- a/test/PCH/cxx-templates.cpp +++ b/test/PCH/cxx-templates.cpp @@ -1,23 +1,21 @@ // Test this without pch. // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o - -// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s // Test with pch. // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump -o - -// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize -DNO_ERRORS | FileCheck %s // Test with modules. // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fmodules -x c++-header -emit-pch -o %t %S/cxx-templates.h // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fmodules -include-pch %t -verify %s -ast-dump -o - -// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fmodules -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fmodules -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize -DNO_ERRORS | FileCheck %s // Test with pch and delayed template parsing. // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t -verify %s -ast-dump -o - -// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s - -// expected-no-diagnostics +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s // CHECK: define weak_odr void @_ZN2S4IiE1mEv // CHECK: define linkonce_odr void @_ZN2S3IiE1mEv @@ -104,3 +102,9 @@ namespace cyclic_module_load { extern std::valarray<int> x; std::valarray<int> y(x); } + +#ifndef NO_ERRORS +// expected-error@cxx-templates.h:305 {{incomplete}} +template int local_extern::f<int[]>(); // expected-note {{in instantiation of}} +#endif +template int local_extern::g<int[]>(); diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h index ce6b7051ec..992f478e33 100644 --- a/test/PCH/cxx-templates.h +++ b/test/PCH/cxx-templates.h @@ -296,3 +296,18 @@ namespace cyclic_module_load { }; } } + +namespace local_extern { + template<typename T> int f() { + extern int arr[3]; + { + extern T arr; + return sizeof(arr); + } + } + template<typename T> int g() { + extern int arr[3]; + extern T arr; + return sizeof(arr); + } +} |