[clang] [Clang][Lex] Implement CWG3013: Error if #embed parameters were defined as macros (PR #224769)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 07:21:53 PDT 2026
================
@@ -922,6 +928,24 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) {
if (const MacroDefinition MD = getMacroDefinition(&II)) {
const auto *MI = MD.getMacroInfo();
assert(MI && "macro definition with no macro info?");
+ // C++ [cpp.pre]/p4, [cpp.cond]/p9: if one of the pp-tokens of a #embed
+ // directive (or a has-embed-expression) is the identifier limit, prefix,
+ // suffix, or if_empty and that identifier is defined as a macro, the
+ // program is ill-formed.
+ //
+ // Thus, do not continue processing if compiling for C++. C doesn't have
+ // this restriction however, so only issue a warning for C if -Wc++-compat
+ // is enabled.
----------------
Fznamznon wrote:
I find it weird that C++ diverges from C anyhow for a feature that new. Does it actually? That is not good
https://github.com/llvm/llvm-project/pull/224769
More information about the cfe-commits
mailing list