Hi, I stumbled into the bug [1] that I hope can be fixed with a new -W option. A commenter [2] suggested splitting out a minor part in a separate patch first, so that's why the series. I hope I got the formatting right; kindly asking for comments.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92826 [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92826#c6 BR, Gábor Bootstrapped on x86_64-linux. The first part fixes the location of the warning for float128 constants to be that of the literal instead of the expression it is part of in warning messages. PR c/92826 gcc/c-family/ChangeLog: * c-lex.cc (interpret_float): Use the location of the current token for reporting warnings instead of the global input_location. gcc/testsuite/ChangeLog: * c-c++-common/pr92826.c: New test. --- gcc/c-family/c-lex.cc | 3 ++- gcc/testsuite/c-c++-common/pr92826.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/pr92826.c diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc index fef6ae6f457..8065e825e7f 100644 --- a/gcc/c-family/c-lex.cc +++ b/gcc/c-family/c-lex.cc @@ -1263,7 +1263,8 @@ interpret_float (const cpp_token *token, unsigned int flags, return error_mark_node; } else - pedwarn (input_location, OPT_Wpedantic, "non-standard suffix on floating constant"); + pedwarn (token->src_loc, OPT_Wpedantic, + "non-standard suffix on floating constant"); type = c_common_type_for_mode (mode, 0); /* For Q suffix, prefer float128t_type_node (__float128) type diff --git a/gcc/testsuite/c-c++-common/pr92826.c b/gcc/testsuite/c-c++-common/pr92826.c new file mode 100644 index 00000000000..ea2e20c6331 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr92826.c @@ -0,0 +1,6 @@ +/* { dg-options "-pedantic" } */ + +int main() +{ + return 1.0Q > 0.1; /* { dg-warning "12: non-standard suffix on floating constant .-Wpedantic" } */ +} -- 2.34.1