summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp1
-rw-r--r--clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp9
-rw-r--r--clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp17
3 files changed, 24 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index a73c5d3f9bc..d230ec90d77 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4693,6 +4693,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef,
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
TemplateArgLists.addOuterTemplateArguments(None);
+ Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
EnterExpressionEvaluationContext ConstantEvaluated(
SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
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