From 59fef7181c504e1cd540b29109b26474f098c46f Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Wed, 24 Apr 2019 08:50:24 +0000 Subject: Revert r359048: C++ DR2387: a variable template declared wthi The change breaks libc++ with the follwing error: In file included from valarray:4: .../include/c++/v1/valarray:1062:60: error: explicit instantiation declaration of 'valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::valarray(size_t)) ^ .../include/c++/v1/valarray:1063:60: error: explicit instantiation declaration of '~valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::~valarray()) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359076 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CXX/drs/dr0xx.cpp | 7 +-- test/CXX/drs/dr17xx.cpp | 2 +- test/CXX/drs/dr23xx.cpp | 26 ----------- test/CXX/module/module.interface/p3.cpp | 2 +- test/CXX/module/module.interface/p5.cpp | 6 +-- .../CodeGenCXX/cxx1y-variable-template-linkage.cpp | 54 +++------------------- test/SemaCXX/PR10177.cpp | 3 +- test/SemaCXX/warn-unused-filescoped.cpp | 3 +- test/SemaCXX/warn-unused-variables.cpp | 4 +- 9 files changed, 20 insertions(+), 87 deletions(-) delete mode 100644 test/CXX/drs/dr23xx.cpp (limited to 'test') diff --git a/test/CXX/drs/dr0xx.cpp b/test/CXX/drs/dr0xx.cpp index 53bd6f3f05..911aab1747 100644 --- a/test/CXX/drs/dr0xx.cpp +++ b/test/CXX/drs/dr0xx.cpp @@ -869,17 +869,18 @@ namespace dr68 { // dr68: yes } namespace dr69 { // dr69: yes - template static void f() {} // #dr69-f + template static void f() {} // FIXME: Should we warn here? inline void g() { f(); } - extern template void f(); // expected-error {{explicit instantiation declaration of 'f' with internal linkage}} + // FIXME: This should be rejected, per [temp.explicit]p11. + extern template void f(); #if __cplusplus < 201103L // expected-error@-2 {{C++11 extension}} #endif template struct Q {}; Q<&f > q; #if __cplusplus < 201103L - // expected-error@-2 {{internal linkage}} expected-note@#dr69-f {{here}} + // expected-error@-2 {{internal linkage}} expected-note@-11 {{here}} #endif } diff --git a/test/CXX/drs/dr17xx.cpp b/test/CXX/drs/dr17xx.cpp index bf7458ea81..9f67b24271 100644 --- a/test/CXX/drs/dr17xx.cpp +++ b/test/CXX/drs/dr17xx.cpp @@ -77,7 +77,7 @@ namespace dr1758 { // dr1758: 3.7 #endif } -namespace dr1722 { // dr1722: 9 +namespace dr1722 { // dr1722: 9.0 #if __cplusplus >= 201103L void f() { const auto lambda = [](int x) { return x + 1; }; diff --git a/test/CXX/drs/dr23xx.cpp b/test/CXX/drs/dr23xx.cpp deleted file mode 100644 index 87db0d4c9b..0000000000 --- a/test/CXX/drs/dr23xx.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus <= 201103L -// expected-no-diagnostics -#endif - -namespace dr2387 { // dr2387: 9 -#if __cplusplus >= 201402L - template int a = 0; - extern template int a<0>; // ok - - template static int b = 0; - extern template int b<0>; // expected-error {{internal linkage}} - - template const int c = 0; - extern template const int c<0>; // ok, has external linkage despite 'const' - - template T d = 0; - extern template int d; - extern template const int d; -#endif -} diff --git a/test/CXX/module/module.interface/p3.cpp b/test/CXX/module/module.interface/p3.cpp index 29d2cb43b4..2bf1f334e1 100644 --- a/test/CXX/module/module.interface/p3.cpp +++ b/test/CXX/module/module.interface/p3.cpp @@ -48,7 +48,7 @@ export namespace { int c; } // expected-error {{declaration of 'c' with internal namespace { // expected-note {{here}} export int d; // expected-error {{export declaration appears within anonymous namespace}} } -export template static int e; // expected-error {{declaration of 'e' with internal linkage cannot be exported}} +export template static int e; // FIXME export template static int f(); // expected-error {{declaration of 'f' with internal linkage cannot be exported}} export const int k = 5; export static union { int n; }; // expected-error {{declaration of 'n' with internal linkage cannot be exported}} diff --git a/test/CXX/module/module.interface/p5.cpp b/test/CXX/module/module.interface/p5.cpp index 17c4105baa..c4299dc04f 100644 --- a/test/CXX/module/module.interface/p5.cpp +++ b/test/CXX/module/module.interface/p5.cpp @@ -14,7 +14,7 @@ static union { int sg1, sg2; }; // expected-note {{target}} namespace NS {} template int ta; -template static int sta; // expected-note {{target}} +template static int sta; template void tb(); template static void stb(); // expected-note {{target}} template struct tc {}; @@ -44,7 +44,7 @@ namespace UnnamedNS { } } -export { // expected-note 19{{here}} +export { // expected-note 18{{here}} using ::a; using ::sa; // expected-error {{using declaration referring to 'sa' with internal linkage}} using ::b; @@ -56,7 +56,7 @@ export { // expected-note 19{{here}} using ::sg1; // expected-error {{using declaration referring to 'sg1' with internal linkage}} using ::ta; - using ::sta; // expected-error {{using declaration referring to 'sta' with internal linkage}} + using ::sta; // FIXME {{using declaration referring to 'sta' with internal linkage}} using ::tb; using ::stb; // expected-error {{using declaration referring to 'stb' with internal linkage}} using ::tc; diff --git a/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp b/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp index c77841cabc..bc775568aa 100644 --- a/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp +++ b/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp @@ -6,61 +6,21 @@ // should be 'internal global' and not 'linkonce_odr global'. template int x = 42; -// CHECK-DAG: @_Z1xIiE = linkonce_odr global -// CHECK-DAG: @_Z1xIZL3foovE3FooE = internal global - -// 'static' affects the linkage of the global -template static int y = 42; -// CHECK-DAG: @_ZL1yIiE = internal global -// CHECK-DAG: @_ZL1yIZL3foovE3FooE = internal global - -// 'const' does not -template const int z = 42; -// CHECK-DAG: @_Z1zIiE = linkonce_odr constant -// CHECK-DAG: @_Z1zIZL3foovE3FooE = internal constant -template T t = 42; -// CHECK-DAG: @_Z1tIiE = linkonce_odr global -// CHECK-DAG: @_Z1tIKiE = linkonce_odr constant - -int mode; +// CHECK-DAG: @_Z1xIZL3foovE3FooE = internal global // CHECK-DAG: define internal dereferenceable(4) i32* @_ZL3foov( -static const int &foo() { +static int &foo() { struct Foo { }; - - switch (mode) { - case 0: - // CHECK-DAG: @_Z1xIiE - return x; - case 1: - // CHECK-DAG: @_Z1xIZL3foovE3FooE - return x; - case 2: - // CHECK-DAG: @_ZL1yIiE - return y; - case 3: - // CHECK-DAG: @_ZL1yIZL3foovE3FooE - return y; - case 4: - // CHECK-DAG: @_Z1zIiE - return z; - case 5: - // CHECK-DAG: @_Z1zIZL3foovE3FooE - return z; - case 6: - // CHECK-DAG: @_Z1tIiE - return t; - case 7: - // CHECK-DAG: @_Z1tIKiE - return t; - } + + // CHECK-DAG: ret i32* @_Z1xIZL3foovE3FooE + return x; } #if !__has_feature(cxx_exceptions) // File A // CHECKA-DAG: define dereferenceable(4) i32* @_Z3barv( -const int &bar() { +int &bar() { // CHECKA-DAG: call dereferenceable(4) i32* @_ZL3foov() return foo(); } @@ -68,7 +28,7 @@ const int &bar() { #else // File B // CHECKB-DAG: declare dereferenceable(4) i32* @_Z3barv( -const int &bar(); +int &bar(); int main() { // CHECKB-DAG: call dereferenceable(4) i32* @_Z3barv() diff --git a/test/SemaCXX/PR10177.cpp b/test/SemaCXX/PR10177.cpp index 0d2e792f52..59630be508 100644 --- a/test/SemaCXX/PR10177.cpp +++ b/test/SemaCXX/PR10177.cpp @@ -57,10 +57,11 @@ namespace N { } #else +// expected-no-diagnostics namespace { template extern int n; } template int g() { return n; } -namespace { extern template int n; } // expected-error {{explicit instantiation declaration of 'n' with internal linkage}} +namespace { extern template int n; } #endif diff --git a/test/SemaCXX/warn-unused-filescoped.cpp b/test/SemaCXX/warn-unused-filescoped.cpp index e052ecb1af..93c6bbd7ed 100644 --- a/test/SemaCXX/warn-unused-filescoped.cpp +++ b/test/SemaCXX/warn-unused-filescoped.cpp @@ -207,9 +207,8 @@ static void completeRedeclChainForTemplateSpecialization() { } // expected-warni namespace test10 { #if __cplusplus >= 201103L -// FIXME: Warn on template definitions with no instantiations? template -constexpr T pi = T(3.14); +constexpr T pi = T(3.14); // expected-warning {{unused}} #endif } diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp index 97634ac43c..a7ac9afc36 100644 --- a/test/SemaCXX/warn-unused-variables.cpp +++ b/test/SemaCXX/warn-unused-variables.cpp @@ -135,9 +135,7 @@ namespace PR19305 { template int m = 0; template int m = 0; - // This has external linkage, so could be referenced by a declaration in a - // different translation unit. - template<> const int m = 0; // no warning + template<> const int m = 0; // expected-warning {{unused variable}} } namespace ctor_with_cleanups { -- cgit v1.2.1