Skip to content

Commit ce40f50

Browse files
committed
[Clang] [NFC] Introduce helpers for defining compatibilty warnings
1 parent 15c96d6 commit ce40f50

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

clang/include/clang/Basic/Diagnostic.td

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,49 @@ class DefaultWarnNoWerror {
155155
}
156156
class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
157157

158+
// C++ compatibility warnings
159+
multiclass CXXCompatWarn<
160+
string message,
161+
bit default_ignore,
162+
int std_ver,
163+
string std_ver_override = ""#std_ver> {
164+
// 'X is a C++YZ extension'.
165+
def compat_pre_cxx#std_ver#_#NAME :
166+
Diagnostic<!strconcat(message, " a C++", std_ver_override, " extension"),
167+
CLASS_EXTENSION,
168+
!if(default_ignore, SEV_Ignored, SEV_Warning)>,
169+
InGroup<!cast<DiagGroup>("CXX"#std_ver)>;
170+
171+
// 'X is incompatible with C++98' (if std_ver == 11).
172+
// 'X is incompatible with C++ standards before C++YZ' (otherwise).
173+
def compat_cxx#std_ver#_#NAME :
174+
Warning<!if(!eq(std_ver, 11),
175+
!strconcat(message, " incompatible with C++98"),
176+
!strconcat(message, " incompatible with C++ standards before C++", std_ver_override))>,
177+
InGroup<!cast<DiagGroup>(!if(!eq(std_ver, 11),
178+
"CXX98Compat",
179+
"CXXPre"#std_ver#"Compat"))>,
180+
DefaultIgnore;
181+
}
182+
183+
multiclass CXX11CompatWarn<string message, bit default_ignore = false>
184+
: CXXCompatWarn<message, default_ignore, 11>;
185+
186+
multiclass CXX14CompatWarn<string message, bit default_ignore = false>
187+
: CXXCompatWarn<message, default_ignore, 14>;
188+
189+
multiclass CXX17CompatWarn<string message, bit default_ignore = false>
190+
: CXXCompatWarn<message, default_ignore, 17>;
191+
192+
multiclass CXX20CompatWarn<string message, bit default_ignore = false>
193+
: CXXCompatWarn<message, default_ignore, 20>;
194+
195+
multiclass CXX23CompatWarn<string message, bit default_ignore = false>
196+
: CXXCompatWarn<message, default_ignore, 23>;
197+
198+
multiclass CXX26CompatWarn<string message, bit default_ignore = false>
199+
: CXXCompatWarn<message, default_ignore, 26, "2c">;
200+
158201
// Definitions for Diagnostics.
159202
include "DiagnosticASTKinds.td"
160203
include "DiagnosticCommentKinds.td"

0 commit comments

Comments
 (0)