Skip to content

Commit 60a085b

Browse files
committed
Revert "[clang] deprecate frelaxed-template-template-args, make it on by default"
This reverts commit 2d7fba5. The patch was reverted because it caused regression with rocThrust due to ambiguity of template specialization. For details please see https://reviews.llvm.org/D109496
1 parent 37f96cb commit 60a085b

17 files changed

+58
-70
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def warn_drv_diagnostics_hotness_requires_pgo : Warning<
355355
def warn_drv_clang_unsupported : Warning<
356356
"the clang compiler does not support '%0'">;
357357
def warn_drv_deprecated_arg : Warning<
358-
"argument '%0' is deprecated%select{|, use '%2' instead}1">, InGroup<Deprecated>;
358+
"argument '%0' is deprecated, use '%1' instead">, InGroup<Deprecated>;
359359
def warn_drv_assuming_mfloat_abi_is : Warning<
360360
"unknown platform, assuming -mfloat-abi=%0">;
361361
def warn_ignoring_ftabstop_value : Warning<

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions")
149149
LANGOPT(GNUAsm , 1, 1, "GNU-style inline assembly")
150150
LANGOPT(Coroutines , 1, 0, "C++20 coroutines")
151151
LANGOPT(DllExportInlines , 1, 1, "dllexported classes dllexport inline methods")
152-
LANGOPT(RelaxedTemplateTemplateArgs, 1, 1, "C++17 relaxed matching of template template arguments")
152+
LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of template template arguments")
153153

154154
LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for all language standard modes")
155155

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,9 +2335,9 @@ defm application_extension : BoolFOption<"application-extension",
23352335
PosFlag<SetTrue, [CC1Option], "Restrict code to those available for App Extensions">,
23362336
NegFlag<SetFalse>>;
23372337
defm relaxed_template_template_args : BoolFOption<"relaxed-template-template-args",
2338-
LangOpts<"RelaxedTemplateTemplateArgs">, DefaultTrue,
2339-
PosFlag<SetTrue>,
2340-
NegFlag<SetFalse, [CC1Option], "Disable C++17 relaxed template template argument matching">>;
2338+
LangOpts<"RelaxedTemplateTemplateArgs">, DefaultFalse,
2339+
PosFlag<SetTrue, [CC1Option], "Enable C++17 relaxed template template argument matching">,
2340+
NegFlag<SetFalse>>;
23412341
defm sized_deallocation : BoolFOption<"sized-deallocation",
23422342
LangOpts<"SizedDeallocation">, DefaultFalse,
23432343
PosFlag<SetTrue, [CC1Option], "Enable C++14 sized global deallocation functions">,

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
683683
Arg->claim();
684684
if (LegacySanitizeCoverage != 0) {
685685
D.Diag(diag::warn_drv_deprecated_arg)
686-
<< Arg->getAsString(Args) << true
687-
<< "-fsanitize-coverage=trace-pc-guard";
686+
<< Arg->getAsString(Args) << "-fsanitize-coverage=trace-pc-guard";
688687
}
689688
continue;
690689
}
@@ -719,11 +718,11 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
719718
// enabled.
720719
if (CoverageFeatures & CoverageTraceBB)
721720
D.Diag(clang::diag::warn_drv_deprecated_arg)
722-
<< "-fsanitize-coverage=trace-bb" << true
721+
<< "-fsanitize-coverage=trace-bb"
723722
<< "-fsanitize-coverage=trace-pc-guard";
724723
if (CoverageFeatures & Coverage8bitCounters)
725724
D.Diag(clang::diag::warn_drv_deprecated_arg)
726-
<< "-fsanitize-coverage=8bit-counters" << true
725+
<< "-fsanitize-coverage=8bit-counters"
727726
<< "-fsanitize-coverage=trace-pc-guard";
728727

729728
int InsertionPointTypes = CoverageFunc | CoverageBB | CoverageEdge;
@@ -733,7 +732,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
733732
if ((CoverageFeatures & InsertionPointTypes) &&
734733
!(CoverageFeatures & InstrumentationTypes)) {
735734
D.Diag(clang::diag::warn_drv_deprecated_arg)
736-
<< "-fsanitize-coverage=[func|bb|edge]" << true
735+
<< "-fsanitize-coverage=[func|bb|edge]"
737736
<< "-fsanitize-coverage=[func|bb|edge],[trace-pc-guard|trace-pc]";
738737
}
739738

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6391,14 +6391,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
63916391
options::OPT_fno_assume_sane_operator_new))
63926392
CmdArgs.push_back("-fno-assume-sane-operator-new");
63936393

6394-
// -frelaxed-template-template-args is deprecated and on by default.
6395-
if (Arg *A =
6396-
Args.getLastArg(options::OPT_frelaxed_template_template_args,
6397-
options::OPT_fno_relaxed_template_template_args)) {
6398-
D.Diag(diag::warn_drv_deprecated_arg) << A->getAsString(Args) << false;
6399-
if (A->getOption().matches(options::OPT_fno_relaxed_template_template_args))
6400-
CmdArgs.push_back("-fno-relaxed-template-template-args");
6401-
}
6394+
// -frelaxed-template-template-args is off by default, as it is a severe
6395+
// breaking change until a corresponding change to template partial ordering
6396+
// is provided.
6397+
if (Args.hasFlag(options::OPT_frelaxed_template_template_args,
6398+
options::OPT_fno_relaxed_template_template_args, false))
6399+
CmdArgs.push_back("-frelaxed-template-template-args");
64026400

64036401
// -fsized-deallocation is off by default, as it is an ABI-breaking change for
64046402
// most platforms.

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,12 +1890,12 @@ void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
18901890

18911891
// Emit warnings for legacy options even if they are overridden.
18921892
if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
1893-
D.Diag(diag::warn_drv_deprecated_arg)
1894-
<< "-mno-code-object-v3" << true << "-mcode-object-version=2";
1893+
D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
1894+
<< "-mcode-object-version=2";
18951895

18961896
if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
1897-
D.Diag(diag::warn_drv_deprecated_arg)
1898-
<< "-mcode-object-v3" << true << "-mcode-object-version=3";
1897+
D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
1898+
<< "-mcode-object-version=3";
18991899

19001900
if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
19011901
if (CodeObjArg->getOption().getID() ==

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7407,7 +7407,9 @@ bool Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
74077407
// C++1z [temp.arg.template]p3: (DR 150)
74087408
// A template-argument matches a template template-parameter P when P
74097409
// is at least as specialized as the template-argument A.
7410-
// FIXME: RelaxedTemplateTemplateArgs is deprecated, should be always on.
7410+
// FIXME: We should enable RelaxedTemplateTemplateArgs by default as it is a
7411+
// defect report resolution from C++17 and shouldn't be introduced by
7412+
// concepts.
74117413
if (getLangOpts().RelaxedTemplateTemplateArgs) {
74127414
// Quick check for the common case:
74137415
// If P contains a parameter pack, then A [...] matches P if each of A's

clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -std=c++2a -verify %s
1+
// RUN: %clang_cc1 -std=c++2a -frelaxed-template-template-args -verify %s
22

33
template<typename T> concept C = T::f();
44
// expected-note@-1{{similar constraint}}

clang/test/Driver/frelaxed-template-template-args.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

clang/test/Lexer/cxx-features.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -fsized-deallocation -verify %s
66
// RUN: %clang_cc1 -std=c++2b -fcxx-exceptions -fsized-deallocation -verify %s
77
//
8-
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -fno-relaxed-template-template-args -DNO_RELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
8+
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
99
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -DCONCEPTS_TS=1 -verify %s
1010
// RUN: %clang_cc1 -std=c++14 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
1111
// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
@@ -195,9 +195,9 @@
195195
#error "wrong value for __cpp_nontype_template_args"
196196
#endif
197197

198-
#if defined(NO_RELAXED_TEMPLATE_TEMPLATE_ARGS) \
199-
? check(template_template_args, 0, 0, 0, 0, 0, 0) \
200-
: check(template_template_args, 201611, 201611, 201611, 201611, 201611, 201611)
198+
#if defined(RELAXED_TEMPLATE_TEMPLATE_ARGS) \
199+
? check(template_template_args, 0, 0, 0, 201611, 201611, 201611) \
200+
: check(template_template_args, 0, 0, 0, 0, 0, 0)
201201
#error "wrong value for __cpp_template_template_args"
202202
#endif
203203

clang/test/SemaTemplate/deduction.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,12 @@ struct Replace<const T, Arg1, Arg2> {
6060
// Replacement of templates
6161
template<template<typename> class TT, typename T1, typename Arg1, typename Arg2>
6262
struct Replace<TT<T1>, Arg1, Arg2> {
63-
// expected-note@-1 2 {{partial specialization matches}}
6463
typedef TT<typename Replace<T1, Arg1, Arg2>::type> type;
6564
};
6665

6766
template<template<typename, typename> class TT, typename T1, typename T2,
6867
typename Arg1, typename Arg2>
6968
struct Replace<TT<T1, T2>, Arg1, Arg2> {
70-
// expected-note@-1 2 {{partial specialization matches}}
7169
typedef TT<typename Replace<T1, Arg1, Arg2>::type,
7270
typename Replace<T2, Arg1, Arg2>::type> type;
7371
};
@@ -81,19 +79,8 @@ struct Replace<TT<T1, _2>, Arg1, Arg2> {
8179

8280
int array0[is_same<Replace<_1, int, float>::type, int>::value? 1 : -1];
8381
int array1[is_same<Replace<const _1, int, float>::type, const int>::value? 1 : -1];
84-
8582
int array2[is_same<Replace<vector<_1>, int, float>::type, vector<int> >::value? 1 : -1];
86-
// expected-error@-1 {{ambiguous partial specializations of 'Replace<vector<_1>, int, float>'}}
87-
// FIXME: Some bad error recovery from the parser here:
88-
// expected-error@-3 {{expected '(' for function-style cast or type construction}}
89-
// expected-error@-4 {{no member named 'value' in the global namespace}}
90-
9183
int array3[is_same<Replace<vector<const _1>, int, float>::type, vector<const int> >::value? 1 : -1];
92-
// expected-error@-1 {{ambiguous partial specializations of 'Replace<vector<const _1>, int, float>'}}
93-
// FIXME: Some bad error recovery from the parser here:
94-
// expected-error@-3 {{expected '(' for function-style cast or type construction}}
95-
// expected-error@-4 {{no member named 'value' in the global namespace}}
96-
9784
int array4[is_same<Replace<vector<int, _2>, double, float>::type, vector<int, float> >::value? 1 : -1];
9885

9986
// PR5911

clang/test/SemaTemplate/default-arguments.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ template<typename T, template<typename> class X = T::template apply>
112112
int array4[is_same<X4<add_pointer>,
113113
X4<add_pointer, add_pointer::apply> >::value? 1 : -1];
114114

115-
template<int> struct X5 {};
115+
template<int> struct X5 {}; // expected-note{{has a different type 'int'}}
116116
template<long> struct X5b {};
117117
template<typename T,
118-
template<T> class B = X5>
118+
template<T> class B = X5> // expected-error{{template template argument has different}} \
119+
// expected-note{{previous non-type template parameter}}
119120
struct X6 {};
120121

121122
X6<int> x6a;
122-
X6<long> x6b;
123+
X6<long> x6b; // expected-note{{while checking a default template argument}}
123124
X6<long, X5b> x6c;
124125

125126

clang/test/SemaTemplate/instantiate-template-template-parm.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,30 @@ apply<add_reference, int>::type ir = i;
2020
apply<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot bind to a value of unrelated type 'int'}}
2121

2222
// Template template parameters
23-
template<int> struct B;
23+
template<int> struct B; // expected-note{{has a different type 'int'}}
2424

2525
template<typename T,
26-
template<T Value> class X> // expected-error{{cannot have type 'float'}}
26+
template<T Value> class X> // expected-error{{cannot have type 'float'}} \
27+
// expected-note{{with type 'long'}}
2728
struct X0 { };
2829

2930
X0<int, B> x0b1;
3031
X0<float, B> x0b2; // expected-note{{while substituting}}
31-
X0<long, B> x0b3;
32+
X0<long, B> x0b3; // expected-error{{template template argument has different template parameters}}
3233

33-
template<template<int V> class TT>
34+
template<template<int V> class TT> // expected-note{{parameter with type 'int'}}
3435
struct X1 { };
3536

3637
template<typename T, template<T V> class TT>
3738
struct X2 {
38-
X1<TT> x1;
39+
X1<TT> x1; // expected-error{{has different template parameters}}
3940
};
4041

4142
template<int V> struct X3i { };
42-
template<long V> struct X3l { };
43+
template<long V> struct X3l { }; // expected-note{{different type 'long'}}
4344

4445
X2<int, X3i> x2okay;
45-
X2<long, X3l> x2bad;
46+
X2<long, X3l> x2bad; // expected-note{{instantiation}}
4647

4748
template <typename T, template <T, T> class TT, class R = TT<1, 2> >
4849
struct Comp {

clang/test/SemaTemplate/nested-template.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,18 @@ template struct X1<int>::B<bool>;
112112
// Template template parameters
113113
template<typename T>
114114
struct X2 {
115-
template<template<class U, T Value> class> // expected-error{{cannot have type 'float'}}
115+
template<template<class U, T Value> class> // expected-error{{cannot have type 'float'}} \
116+
// expected-note{{previous non-type template}}
116117
struct Inner { };
117118
};
118119

119-
template<typename T, int Value>
120+
template<typename T,
121+
int Value> // expected-note{{template non-type parameter}}
120122
struct X2_arg;
121123

122124
X2<int>::Inner<X2_arg> x2i1;
123125
X2<float> x2a; // expected-note{{instantiation}}
124-
X2<long>::Inner<X2_arg> x2i3;
126+
X2<long>::Inner<X2_arg> x2i3; // expected-error{{template template argument has different}}
125127

126128
namespace PR10896 {
127129
template<typename TN>

clang/test/SemaTemplate/temp_arg_template.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ template<template<typename T> class X> struct A; // expected-note 2{{previous te
66

77
template<template<typename T, int I> class X> struct B; // expected-note{{previous template template parameter is here}}
88

9-
template<template<int I> class X> struct C; // expected-note {{previous non-type template parameter with type 'int' is here}}
9+
template<template<int I> class X> struct C; // expected-note 2{{previous non-type template parameter with type 'int' is here}}
1010

1111
template<class> struct X; // expected-note{{too few template parameters in template template argument}}
1212
template<int N> struct Y; // expected-note{{template parameter has a different kind in template argument}}
13-
template<long N> struct Ylong;
13+
template<long N> struct Ylong; // expected-note{{template non-type parameter has a different type 'long' in template argument}}
1414
template<const int &N> struct Yref; // expected-note{{template non-type parameter has a different type 'const int &' in template argument}}
1515

1616
namespace N {
@@ -27,7 +27,7 @@ A<Y> *a4; // expected-error{{template template argument has different template p
2727
A<TooMany> *a5; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
2828
B<X> *a6; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
2929
C<Y> *a7;
30-
C<Ylong> *a8;
30+
C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
3131
C<Yref> *a9; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
3232

3333
template<typename T> void f(int);

clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -frelaxed-template-template-args %s
22

33
// expected-note@temp_arg_template_cxx1z.cpp:* 1+{{}}
44

clang/www/cxx_status.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ <h2 id="cxx17">C++17 implementation status</h2>
596596
<p>You can use Clang in C++17 mode with the <code>-std=c++17</code> option
597597
(use <code>-std=c++1z</code> in Clang 4 and earlier).</p>
598598

599-
<details>
599+
<details open>
600600
<summary>List of features and minimum Clang version with support</summary>
601601

602602
<table width="689" border="1" cellspacing="0">
@@ -813,8 +813,8 @@ <h2 id="cxx17">C++17 implementation status</h2>
813813
<!-- Issaquah 2016 papers -->
814814
<tr>
815815
<td>Matching template template parameters to compatible arguments</td>
816-
<td><a href="https://wg21.link/p0522r0">P0522R0</a> (<a href="#dr">DR</a>)</td>
817-
<td class="full" align="center">Clang 4 <a href="#p0522">(10)</a></td>
816+
<td><a href="https://wg21.link/p0522r0">P0522R0</a></td>
817+
<td class="partial" align="center">Partial <a href="#p0522">(10)</a></td>
818818
</tr>
819819
<tr>
820820
<td>Removing deprecated dynamic exception specifications</td>
@@ -842,10 +842,13 @@ <h2 id="cxx17">C++17 implementation status</h2>
842842
reverse construction order in that ABI.
843843
This is not fully supported during constant expression evaluation until Clang 12.
844844
</span><br>
845-
<span id="p0522">(10): Prior to Clang 14, this feature is not enabled by
846-
default, but can be enabled with <tt>-frelaxed-template-template-args</tt>.
847-
Starting from Clang 14, the flag is deprecated and will be removed in a future
848-
version.
845+
<span id="p0522">(10): Despite being the resolution to a Defect Report, this
846+
feature is disabled by default in all language versions, and can be enabled
847+
explicitly with the flag <tt>-frelaxed-template-template-args</tt> in Clang 4
848+
onwards.
849+
The change to the standard lacks a corresponding change for template partial
850+
ordering, resulting in ambiguity errors for reasonable and previously-valid
851+
code. This issue is expected to be rectified soon.
849852
</span>
850853
</p>
851854
</details>

0 commit comments

Comments
 (0)