summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-08-24 02:30:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-08-24 02:30:00 +0000
commitcb167c85b468b1f3876d1b3545713703fd61faa0 (patch)
treee06c9c9ce84c63f6273f01a8c20984b180fb1523 /clang/test
parent3f6dd0c588726b2303986c4a669451ae61b34c1e (diff)
downloadbcm5719-llvm-cb167c85b468b1f3876d1b3545713703fd61faa0.tar.gz
bcm5719-llvm-cb167c85b468b1f3876d1b3545713703fd61faa0.zip
PR42513: Enter the proper DeclContext before substituting into an
default template argument expression. We already did this for type template parameters and template template parameters, but apparently forgot to do so for non-type template parameters. This causes the substituted default argument expression to be substituted in the proper context, and in particular to properly mark its subexpressions as odr-used. llvm-svn: 369834
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp9
-rw-r--r--clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp17
2 files changed, 23 insertions, 3 deletions
diff --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
index c5deb9fe919..85312cf1049 100644
--- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -268,13 +268,16 @@ namespace tuple_tests {
// Don't get caught by surprise when X<...> doesn't even exist in the
// selected specialization!
namespace libcxx_2 {
- template<class ...T> struct tuple { // expected-note {{candidate}}
+ template<class ...T> struct tuple {
template<class ...Args> struct X { static const bool value = false; };
+ // Substitution into X<U...>::value succeeds but produces the
+ // value-dependent expression
+ // tuple<T...>::X<>::value
+ // FIXME: Is that the right behavior?
template<class ...U, bool Y = X<U...>::value> tuple(U &&...u);
- // expected-note@-1 {{substitution failure [with T = <>, U = <int, int, int>]: cannot reference member of primary template because deduced class template specialization 'tuple<>' is an explicit specialization}}
};
template <> class tuple<> {};
- tuple a = {1, 2, 3}; // expected-error {{no viable constructor or deduction guide}}
+ tuple a = {1, 2, 3}; // expected-error {{excess elements in struct initializer}}
}
namespace libcxx_3 {
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
index 313114e2cb8..460b6def5d6 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
@@ -48,3 +48,20 @@ void Useage() {
}
}
+namespace PR42513 {
+ template<typename X, int Ret = WidgetCtor((X*)nullptr)> void f();
+ constexpr int WidgetCtor(struct X1*);
+
+ struct X1 {
+ friend constexpr int WidgetCtor(X1*);
+ };
+ template<typename X1>
+ struct StandardWidget {
+ friend constexpr int WidgetCtor(X1*) {
+ return 0;
+ }
+ };
+ template struct StandardWidget<X1>;
+
+ void use() { f<X1>(); }
+}
OpenPOWER on IntegriCloud