================ @@ -155,6 +155,38 @@ class DefaultWarnNoWerror { } class DefaultRemark { Severity DefaultSeverity = SEV_Remark; } +// C++ compatibility warnings. +multiclass CXXCompat< + string message, + int std_ver, + bit ext_warn = true, + string std_ver_override = ""#std_ver> { + // 'X is a C++YZ extension'. + def compat_pre_cxx#std_ver#_#NAME : + Diagnostic<!strconcat(message, " a C++", std_ver_override, " extension"), + CLASS_EXTENSION, + !if(ext_warn, SEV_Warning, SEV_Ignored)>, + InGroup<!cast<DiagGroup>("CXX"#std_ver)>; + + // 'X is incompatible with C++98' (if std_ver == 11). + // 'X is incompatible with C++ standards before C++YZ' (otherwise). + def compat_cxx#std_ver#_#NAME : + Warning<!if(!eq(std_ver, 11), + !strconcat(message, " incompatible with C++98"), + !strconcat(message, " incompatible with C++ standards before C++", std_ver_override))>, + InGroup<!cast<DiagGroup>(!if(!eq(std_ver, 11), + "CXX98Compat", + "CXXPre"#std_ver#"Compat"))>, + DefaultIgnore; +} + +multiclass CXX11Compat<string message, bit ext_warn = true> : CXXCompat<message, 11, ext_warn>; ---------------- Sirraide wrote:
> Note, we usually have a convention that extension warnings are prefixed with > `ext`, warnings are prefixed with `warn`; should we retain that convention? Well, I currently at least always have to think for like half a minute when issuing a compatibility warning along the lines of ‘so if this is a C++20 feature, then this is a warning about C++17 compatibility, meaning it’s an extension in C++17, so it’s the C++17 warning that starts with `ext_`’. Imo that doesn’t really add too much value and just increases cognitive load (at least that’s how it is for me ;Þ). Also, with compatibility warnings, I don’t think we care too much to know at the call site whether it’s an ExtWarn/Extension or Warning. https://github.com/llvm/llvm-project/pull/132129 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits