[llvm-branch-commits] [cfe-branch] r370038 - Merging r369834:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 27 03:38:25 PDT 2019
Author: hans
Date: Tue Aug 27 03:38:25 2019
New Revision: 370038
URL: http://llvm.org/viewvc/llvm-project?rev=370038&view=rev
Log:
Merging r369834:
------------------------------------------------------------------------
r369834 | rsmith | 2019-08-24 04:30:00 +0200 (Sat, 24 Aug 2019) | 8 lines
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.
------------------------------------------------------------------------
Modified:
cfe/branches/release_90/ (props changed)
cfe/branches/release_90/lib/Sema/SemaTemplate.cpp
cfe/branches/release_90/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
cfe/branches/release_90/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
Propchange: cfe/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 27 03:38:25 2019
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:366429,366447-366448,366457,366474,366480,366483,366511,366670,366694,366699,366878,367008,367039,367055,367103,367134,367301,367305,367323,367387,367403,367520,367530,367661,367675,367802,367823,367906,368104,368202,368552,368561,368874,368940,369043,369093,369251,369641,369749,369829
+/cfe/trunk:366429,366447-366448,366457,366474,366480,366483,366511,366670,366694,366699,366878,367008,367039,367055,367103,367134,367301,367305,367323,367387,367403,367520,367530,367661,367675,367802,367823,367906,368104,368202,368552,368561,368874,368940,369043,369093,369251,369641,369749,369829,369834
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_90/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/lib/Sema/SemaTemplate.cpp?rev=370038&r1=370037&r2=370038&view=diff
==============================================================================
--- cfe/branches/release_90/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/release_90/lib/Sema/SemaTemplate.cpp Tue Aug 27 03:38:25 2019
@@ -4692,6 +4692,7 @@ SubstDefaultTemplateArgument(Sema &SemaR
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);
Modified: cfe/branches/release_90/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=370038&r1=370037&r2=370038&view=diff
==============================================================================
--- cfe/branches/release_90/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp (original)
+++ cfe/branches/release_90/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Tue Aug 27 03:38:25 2019
@@ -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 at -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 {
Modified: cfe/branches/release_90/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/SemaTemplate/temp_arg_nontype_cxx11.cpp?rev=370038&r1=370037&r2=370038&view=diff
==============================================================================
--- cfe/branches/release_90/test/SemaTemplate/temp_arg_nontype_cxx11.cpp (original)
+++ cfe/branches/release_90/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Tue Aug 27 03:38:25 2019
@@ -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>(); }
+}
More information about the llvm-branch-commits
mailing list