-
Notifications
You must be signed in to change notification settings - Fork 15k
Turn -Wdeprecated-literal-operator on by default
#111027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
21dc8df
c45eda6
f9a9f81
c012c62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -503,17 +503,23 @@ bool Sema::checkLiteralOperatorId(const CXXScopeSpec &SS, | |
| const IdentifierInfo *II = Name.Identifier; | ||
| ReservedIdentifierStatus Status = II->isReserved(PP.getLangOpts()); | ||
| SourceLocation Loc = Name.getEndLoc(); | ||
| if (!PP.getSourceManager().isInSystemHeader(Loc)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't clear to me that this check was necessary at all? So I've removed it. Both diags happen now without the check, and unconditionally on each-other. They also share the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need it any longer because I believe we suppress diagnostics in system headers via the diagnostics engine itself; you can test it out by using GNU line markers to pretend some code is a system header: https://godbolt.org/z/PsaM19Pe8 |
||
| if (auto Hint = FixItHint::CreateReplacement( | ||
| Name.getSourceRange(), | ||
| (StringRef("operator\"\"") + II->getName()).str()); | ||
| isReservedInAllContexts(Status)) { | ||
| Diag(Loc, diag::warn_reserved_extern_symbol) | ||
| << II << static_cast<int>(Status) << Hint; | ||
| } else { | ||
| Diag(Loc, diag::warn_deprecated_literal_operator_id) << II << Hint; | ||
| } | ||
| } | ||
|
|
||
| auto Hint = FixItHint::CreateReplacement( | ||
| Name.getSourceRange(), | ||
| (StringRef("operator\"\"") + II->getName()).str()); | ||
|
|
||
| // Only emit this diagnostic if we start with an underscore, else the | ||
| // diagnostic for C++11 requiring a space between the quotes and the | ||
| // identifier conflicts with this and gets confusing. The diagnostic stating | ||
| // this is a reserved name should force the underscore, which gets this | ||
| // back. | ||
| if (II->isReservedLiteralSuffixId() != | ||
| ReservedLiteralSuffixIdStatus::NotStartsWithUnderscore) | ||
| Diag(Loc, diag::warn_deprecated_literal_operator_id) << II << Hint; | ||
|
|
||
| if (isReservedInAllContexts(Status)) | ||
| Diag(Loc, diag::warn_reserved_extern_symbol) | ||
| << II << static_cast<int>(Status) << Hint; | ||
| } | ||
|
|
||
| if (!SS.isValid()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,18 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s | ||
|
|
||
| int &operator "" _x1 (unsigned long long); | ||
| int &operator ""_x1 (unsigned long long); | ||
| int &i1 = 0x123_x1; | ||
|
|
||
| double &operator "" _x1 (const char *); | ||
| double &operator ""_x1 (const char *); | ||
| int &i2 = 45_x1; | ||
|
|
||
| template<char...> char &operator "" _x1 (); | ||
| template<char...> char &operator ""_x1 (); | ||
| int &i3 = 0377_x1; | ||
|
|
||
| int &i4 = 90000000000000000000000000000000000000000000000_x1; // expected-error {{integer literal is too large to be represented in any integer type}} | ||
|
|
||
| double &operator "" _x2 (const char *); | ||
| double &operator ""_x2 (const char *); | ||
| double &i5 = 123123123123123123123123123123123123123123123_x2; | ||
|
|
||
| template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); } | ||
| template<char...Cs> constexpr int operator ""_x3() { return sizeof...(Cs); } | ||
| static_assert(123456789012345678901234567890123456789012345678901234567890_x3 == 60, ""); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,18 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s | ||
|
|
||
| int &operator "" _x1 (long double); | ||
| int &operator ""_x1 (long double); | ||
| int &i1 = 0.123_x1; | ||
|
|
||
| double &operator "" _x1 (const char *); | ||
| double &operator ""_x1 (const char *); | ||
| int &i2 = 45._x1; | ||
|
|
||
| template<char...> char &operator "" _x1 (); | ||
| template<char...> char &operator ""_x1 (); | ||
| int &i3 = 0377e-1_x1; | ||
|
|
||
| int &i4 = 1e1000000_x1; // expected-warning {{too large for type 'long double'}} | ||
|
|
||
| double &operator "" _x2 (const char *); | ||
| double &operator ""_x2 (const char *); | ||
| double &i5 = 1e1000000_x2; | ||
|
|
||
| template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); } | ||
| template<char...Cs> constexpr int operator ""_x3() { return sizeof...(Cs); } | ||
| static_assert(1e1000000_x3 == 9, ""); |
Uh oh!
There was an error while loading. Please reload this page.