[PATCH] D153156: [Clang] CWG1473: do not err on the lack of space after operator""

PoYao Chang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 10:47:39 PDT 2023


rZhBoYao added a comment.

In D153156#4599324 <https://reviews.llvm.org/D153156#4599324>, @jyknight wrote:

> 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.

Works in C++98 mode tho. TIL people exploit this to mix pre-C++11 code into modern C++. I agree that a reminder for those people in the release note is needed.

> And, if that _was_ an intended change, then we have other diagnostics which need to be fixed up now

Agreed

In D153156#4599292 <https://reviews.llvm.org/D153156#4599292>, @rupprecht wrote:

> IIUC, the question is not whether the diagnostic is correct, but rather why `-Wno-reserved-user-defined-literal` does not workaround the breakage. Is that right?
>
> An example of this in the wild is older versions of swig: https://github.com/swig/swig/blob/939dd5e1c8c17e5f8b38747bf18e9041ab5f377e/Source/Modules/php.cxx#L1724

We simply stop pretending a whitespace precedes an invalid ud-suffix as that affects the grammar production and therefore diagnosis in Sema.
IMHO, people should stop  using `-Wno-reserved-user-defined-literal` and exploiting the addition of a whitespace to mingle pre-c++11 and post-c++11 code.
What if a programmer is really trying to call operator""b here (albeit ill-formed):

  const char* operator""b(const char*, decltype(sizeof 0));
  const char* f() {
  #define b "a"
    return "ONE"b; // NOW: IFNDR but calls operator""b
                   //
                   // BEFORE: string concat by exploiting the impl of
                   // ext_reserved_user_defined_literal (controlled by
                   // -Wreserved-user-defined-literal diag group)
  }


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