From 7dfa657b5bae61a458721d079320fb82401ed58b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sun, 19 Feb 2017 14:13:53 +0000 Subject: [PATCH] PR c++/69523 make -Wliteral-suffix control warning gcc: PR c++/69523 * doc/invoke.texi (C++ Dialect Options) [-Wliteral-suffix]: Update description. gcc/cp: 2017-02-19 Eric Fiselier Jonathan Wakely PR c++/69523 * parser.c (cp_parser_unqualified_id): Use OPT_Wliteral_suffix to control warning about literal suffix identifiers without a leading underscore. gcc/testsuite: 2017-02-19 Eric Fiselier Jonathan Wakely PR c++/69523 * g++.dg/cpp0x/Wliteral-suffix2.C: New test. From-SVN: r245574 --- gcc/ChangeLog | 6 ++++++ gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/parser.c | 5 +++-- gcc/doc/invoke.texi | 5 +++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C | 11 +++++++++++ 6 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b7bc561707..d404f8f3e48 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-02-19 Jonathan Wakely + + PR c++/69523 + * doc/invoke.texi (C++ Dialect Options) [-Wliteral-suffix]: Update + description. + 2017-02-19 Prathamesh Kulkarni * gimple-pretty-print.c (dump_ternary_rhs): Adjust gimple dump format diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8dce6d18fea..d0803bfa433 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2017-02-19 Eric Fiselier + Jonathan Wakely + + PR c++/69523 + * parser.c (cp_parser_unqualified_id): Use OPT_Wliteral_suffix to + control warning about literal suffix identifiers without a leading + underscore. + 2017-02-17 Jason Merrill PR c++/79508 - lookup error with member template diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 92d8ccea95b..feeafcec6ad 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5812,8 +5812,9 @@ cp_parser_unqualified_id (cp_parser* parser, const char *name = UDLIT_OP_SUFFIX (id); if (name[0] != '_' && !in_system_header_at (input_location) && declarator_p) - warning (0, "literal operator suffixes not preceded by %<_%>" - " are reserved for future standardization"); + warning (OPT_Wliteral_suffix, + "literal operator suffixes not preceded by %<_%>" + " are reserved for future standardization"); } return id; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c65086cb3a8..6e219dab4d3 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2852,6 +2852,11 @@ int main() @{ In this case, @code{PRId64} is treated as a separate preprocessing token. +Additionally, warn when a user-defined literal operator is declared with +a literal suffix identifier that doesn't begin with an underscore. Literal +suffix identifiers that don't begin with an underscore are reserved for +future standardization. + This warning is enabled by default. @item -Wlto-type-mismatch diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 97f392a1ac6..c98d77481c6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-02-19 Eric Fiselier + Jonathan Wakely + + PR c++/69523 + * g++.dg/cpp0x/Wliteral-suffix2.C: New test. + 2017-02-19 Prathamesh Kulkarni * gcc.dg/gimplefe-26.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C b/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C new file mode 100644 index 00000000000..129947d86b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-literal-suffix" } + +// Test user-defined literals. +// Test "-Wno-literal-suffix" suppresses warnings on declaration without +// leading underscore. + +long double operator"" nounder(long double); // { dg-bogus "" } + +template + int operator"" nounder(); // { dg-bogus "" } -- 2.30.2