[PATCH] D153156: [Clang] CWG1473: do not err on the lack of space after operator""
James Y Knight via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 18 09:17:47 PDT 2023
jyknight added a comment.
> The diagnostic behavior is correct. MYTHING doesn't get expanded until phase 4 (http://eel.is/c++draft/lex.phases#1.4), so this appears as "ONE"MYTHING as a single preprocessor token: https://eel.is/c++draft/lex.ext#nt:user-defined-string-literal and that token is an invalid UDL.
Correct per the specification, but the purpose of `-Wno-reserved-user-defined-literal` is to precisely to permit such pre-C++11 code like the example above to continue to compile. This change breaks that option. (Note that it is an error-by-default "warning".)
If proper spec-conformance means we can no longer support the ability to allow such out-of-spec pre-c++11 code to work anymore, that's probably OK...but, in that case, we also need to eliminate the warning option, and mention the change in the release notes.
However, it's unclear to me why we need to do so, since the spec says you're not allowed to define UDL without an underscore prefix
` float operator ""E(const char*); // ill-formed, no diagnostic required:`
Yet, what this change does, and why it breaks the above functionality, is that it now allows defining and calling user-defined literal operators which don't begin with an underscore. That seems like a potentially undesirable change?
And, if that _was_ an intended change, then we have other diagnostics which need to be fixed up now:
const char*operator ""foo(const char *, unsigned long);
const char* f() {
return "hi"foo;
}
emits `<source>:1:12: warning: user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator [-Wuser-defined-literals]` and yet, now it does invoke the operator...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153156/new/
https://reviews.llvm.org/D153156
More information about the cfe-commits
mailing list