llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Shengxin Pei (TPPPP72) <details> <summary>Changes</summary> I am not sure if I misunderstood #<!-- -->192490. I discovered that the current diagnostic engine actually already possesses this kind of attribute. It simply wasn't being utilized previously. I have partially reverted the changes from #<!-- -->192481. However, since I am uncertain whether modifying the warnings related to binary literals might have side effects, I have decided not to alter that part for the time being, pending the initial review. --- Full diff: https://github.com/llvm/llvm-project/pull/228035.diff 2 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (+4-4) - (modified) clang/lib/Lex/LiteralSupport.cpp (+3-13) ``````````diff diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index ff51485a1810b..3389890d1b2c1 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -269,16 +269,16 @@ def err_hex_constant_requires : Error< def ext_hex_constant_invalid : Extension< "hexadecimal floating constants are a C99 feature">, InGroup<C99>; def ext_octal_literal : Extension< - "octal integer literals are a C2y extension">, InGroup<C2y>; + "octal integer literals are a C2y extension">, InGroup<C2y>, SuppressInSystemMacro; def ext_cpp_octal_literal : Extension< "octal integer literals are a Clang extension">, - InGroup<DiagGroup<"octal-prefix-extension">>; + InGroup<DiagGroup<"octal-prefix-extension">>, SuppressInSystemMacro; def warn_c2y_compat_octal_literal : Warning< "octal integer literals are incompatible with standards before C2y">, - InGroup<CPre2yCompat>, DefaultIgnore; + InGroup<CPre2yCompat>, DefaultIgnore, SuppressInSystemMacro; def warn_unprefixed_octal_deprecated : Warning< "octal literals without a '0o' prefix are deprecated">, - InGroup<DeprecatedOctalLiterals>; + InGroup<DeprecatedOctalLiterals>, SuppressInSystemMacro; def ext_binary_literal : Extension< "binary integer literals are a C23 extension">, InGroup<C23>; def warn_c23_compat_binary_literal : Warning< diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index d8cceec27e101..efb1138b46615 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -1495,14 +1495,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { DiagId = diag::ext_cpp_octal_literal; else DiagId = diag::ext_octal_literal; - // If the token location is from a macro expansion where the macro was - // defined in a system header, suppress the diagnostic. - // FIXME: this is actually a more general issue, for example we have a - // similar need for binary literals above. It would be best for this to be - // handled by the diagnostics engine instead of with ad hoc solutions. This - // same concern exists below for issuing the deprecation warning. - if (!SM.isInSystemMacro(TokLoc)) - Diags.Report(TokLoc, DiagId); + Diags.Report(TokLoc, DiagId); ++s; DigitsBegin = s; @@ -1524,11 +1517,8 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { llvm::scope_exit _([&] { // If we still have an octal value but we did not see an octal prefix, - // diagnose as being an obsolescent feature starting in C2y. If the token - // location is from a macro expansion where the macro was defined in a - // system header, suppress the diagnostic. - if (radix == 8 && LangOpts.C2y && !hadError && !IsSingleZero && - !SM.isInSystemMacro(TokLoc)) + // diagnose as being an obsolescent feature starting in C2y. + if (radix == 8 && LangOpts.C2y && !hadError && !IsSingleZero) Diags.Report(TokLoc, diag::warn_unprefixed_octal_deprecated); }); `````````` </details> https://github.com/llvm/llvm-project/pull/228035 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
