Skip to content

Commit c227bf1

Browse files
authored
[clang] Create new warning group for deprecation of '-fno-relaxed-template-template-args' (llvm#92324)
This allows the warning to be disabled in isolation, as it helps when treating them as errors.
1 parent 325d1d0 commit c227bf1

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ C++ Specific Potentially Breaking Changes
5151
- The behavior controlled by the `-frelaxed-template-template-args` flag is now
5252
on by default, and the flag is deprecated. Until the flag is finally removed,
5353
it's negative spelling can be used to obtain compatibility with previous
54-
versions of clang.
54+
versions of clang. The deprecation warning for the negative spelling can be
55+
disabled with `-Wno-deprecated-no-relaxed-template-template-args`.
5556

5657
- Clang now rejects pointer to member from parenthesized expression in unevaluated context such as ``decltype(&(foo::bar))``. (#GH40906).
5758

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ def warn_drv_clang_unsupported : Warning<
436436
"the clang compiler does not support '%0'">;
437437
def warn_drv_deprecated_arg : Warning<
438438
"argument '%0' is deprecated%select{|, use '%2' instead}1">, InGroup<Deprecated>;
439+
def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
440+
"argument '-fno-relaxed-template-template-args' is deprecated">,
441+
InGroup<DeprecatedNoRelaxedTemplateTemplateArgs>;
439442
def warn_drv_deprecated_custom : Warning<
440443
"argument '%0' is deprecated, %1">, InGroup<Deprecated>;
441444
def warn_drv_assuming_mfloat_abi_is : Warning<

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
104104
[EnumEnumConversion,
105105
EnumFloatConversion,
106106
EnumCompareConditional]>;
107+
def DeprecatedNoRelaxedTemplateTemplateArgs : DiagGroup<"deprecated-no-relaxed-template-template-args">;
107108
def ObjCSignedCharBoolImplicitIntConversion :
108109
DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
109110
def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
@@ -228,6 +229,7 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
228229
DeprecatedLiteralOperator,
229230
DeprecatedPragma,
230231
DeprecatedRegister,
232+
DeprecatedNoRelaxedTemplateTemplateArgs,
231233
DeprecatedThisCapture,
232234
DeprecatedType,
233235
DeprecatedVolatile,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7253,10 +7253,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
72537253
if (Arg *A =
72547254
Args.getLastArg(options::OPT_frelaxed_template_template_args,
72557255
options::OPT_fno_relaxed_template_template_args)) {
7256-
D.Diag(diag::warn_drv_deprecated_arg)
7257-
<< A->getAsString(Args) << /*hasReplacement=*/false;
7258-
if (A->getOption().matches(options::OPT_fno_relaxed_template_template_args))
7256+
if (A->getOption().matches(
7257+
options::OPT_fno_relaxed_template_template_args)) {
7258+
D.Diag(diag::warn_drv_deprecated_arg_no_relaxed_template_template_args);
72597259
CmdArgs.push_back("-fno-relaxed-template-template-args");
7260+
} else {
7261+
D.Diag(diag::warn_drv_deprecated_arg)
7262+
<< A->getAsString(Args) << /*hasReplacement=*/false;
7263+
}
72607264
}
72617265

72627266
// -fsized-deallocation is off by default, as it is an ABI-breaking change for
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %clang -fsyntax-only -### %s 2>&1 | FileCheck --check-prefix=CHECK-DEF %s
22
// RUN: %clang -fsyntax-only -frelaxed-template-template-args %s 2>&1 | FileCheck --check-prefix=CHECK-ON %s
33
// RUN: %clang -fsyntax-only -fno-relaxed-template-template-args %s 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
4+
// RUN: %clang -fsyntax-only -fno-relaxed-template-template-args -Wno-deprecated-no-relaxed-template-template-args %s 2>&1 | FileCheck --check-prefix=CHECK-DIS --allow-empty %s
45

56
// CHECK-DEF-NOT: "-cc1"{{.*}} "-fno-relaxed-template-template-args"
67
// CHECK-ON: warning: argument '-frelaxed-template-template-args' is deprecated [-Wdeprecated]
7-
// CHECK-OFF: warning: argument '-fno-relaxed-template-template-args' is deprecated [-Wdeprecated]
8+
// CHECK-OFF: warning: argument '-fno-relaxed-template-template-args' is deprecated [-Wdeprecated-no-relaxed-template-template-args]
9+
// CHECK-DIS-NOT: warning: argument '-fno-relaxed-template-template-args' is deprecated

0 commit comments

Comments
 (0)