diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-06 22:52:53 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-06 22:52:53 +0000 |
commit | e5945871cfb954d80cbeb9c99a26f02b41decae6 (patch) | |
tree | 20598a89710fa1f1c7f89b98a972933153da7d49 /clang/test | |
parent | 1fb895e890b095e9b155239d28ec21340aa538de (diff) | |
download | bcm5719-llvm-e5945871cfb954d80cbeb9c99a26f02b41decae6.tar.gz bcm5719-llvm-e5945871cfb954d80cbeb9c99a26f02b41decae6.zip |
Revisit PR10177: don't instantiate a variable if it's only referenced in a
dependent context and can't be used in a constant expression.
Per C++ [temp.inst]p2, "the instantiation of a static data member does not
occur unless the static data member is used in a way that requires the
definition to exist".
This doesn't /quite/ match that, as we still instantiate static data members
that are usable in constant expressions even if the use doesn't require a
definition. A followup patch will fix that for both variables and functions.
llvm-svn: 291295
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/PR10177.cpp | 9 | ||||
-rw-r--r-- | clang/test/SemaCXX/undefined-internal.cpp | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/PR10177.cpp b/clang/test/SemaCXX/PR10177.cpp index 9286e293516..59630be5088 100644 --- a/clang/test/SemaCXX/PR10177.cpp +++ b/clang/test/SemaCXX/PR10177.cpp @@ -24,6 +24,13 @@ void f() { (void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}} }; +template<typename T> +void not_instantiated() { + // These cases (arguably) do not require instantiation of U<i>::a. + (void)alias_ref<int, int&, U<3>::a>(); + (void)func_ref<int, int&, U<4>::a>(); + (void)class_ref<int, int&, U<5>::a>(); +}; template<int N> void fi() { @@ -33,7 +40,7 @@ void fi() { }; int main() { - f<int>(); // NOTE: Non-dependent name uses are type-checked at template definition time. + f<int>(); // expected-note 3{{here}} fi<10>(); // expected-note 3{{here}} } diff --git a/clang/test/SemaCXX/undefined-internal.cpp b/clang/test/SemaCXX/undefined-internal.cpp index 59e6fdf9af0..32151b71ea1 100644 --- a/clang/test/SemaCXX/undefined-internal.cpp +++ b/clang/test/SemaCXX/undefined-internal.cpp @@ -186,10 +186,15 @@ namespace OverloadUse { namespace { void f(); void f(int); // expected-warning {{function 'OverloadUse::(anonymous namespace)::f' has internal linkage but is not defined}} + void f(int, int); // expected-warning {{function 'OverloadUse::(anonymous namespace)::f' has internal linkage but is not defined}} + } + template<void x()> void t() { x(); } + template<void x(int)> void t(int*) { x(10); } + template<void x(int, int)> void t(int*, int*) {} + void g(int n) { + t<f>(&n); // expected-note {{used here}} + t<f>(&n, &n); // expected-note {{used here}} } - template<void x()> void t(int*) { x(); } - template<void x(int)> void t(long*) { x(10); } // expected-note {{used here}} - void g() { long a; t<f>(&a); } } namespace test7 { |