[llvm-bugs] [Bug 50644] New: User-defined literals generate false-positive "Wreserved-identifier"

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 9 09:01:27 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50644

            Bug ID: 50644
           Summary: User-defined literals generate false-positive
                    "Wreserved-identifier"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: al42and at al42and.me
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The C++11 standard requires user-defined suffixes to begin with the underscore.
However they seem to be considered reserved by Clang.

The following code, based on an example from
https://en.cppreference.com/w/cpp/language/user_literal, seems to erroneously
trigger the warning with the most recent commit of clang:

$ cat test.cpp
#include <string>

void operator "" _km(long double);

int main() { return 0; }


$ ./llvm-project/build/bin/clang -Wreserved-identifier -std=c++11 test.cpp
test.cpp:3:6: warning: identifier 'operator""_km' is reserved because it starts
with '_' at global scope [-Wreserved-identifier]
void operator "" _km(long double);
     ^
1 warning generated.

$ ./llvm-project/build/bin/clang --version
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
206a66de5902b2b6dc0c62c4a25526d7e7f24186)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /tmp/./llvm-project/build/bin

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210609/27861003/attachment.html>


More information about the llvm-bugs mailing list