From 1229c56cb93056caccf7af284cc15fe5e4f435f3 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Wed, 4 Apr 2018 19:05:11 +0300 Subject: [PATCH] re PR c++/65923 (False positive for warning about literal operator suffix and using) PR c++/65923 gcc/cp PR c++/65923 * decl.c (grokfndecl): Handle standard UDL diagnostics here.. * parser.c (cp_parser_unqualified_id): ..not here. testsuite/ PR c++/65923 * g++.dg/diagnostic/pr65923.C: New. From-SVN: r259087 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 7 +++++++ gcc/cp/parser.c | 10 ---------- gcc/testsuite/g++.dg/diagnostic/pr65923.C | 23 +++++++++++++++++++++++ 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.dg/diagnostic/pr65923.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 46f05c8661e..0c71d2bd9de 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-04 Ville Voutilainen + + PR c++/65923 + * decl.c (grokfndecl): Handle standard UDL diagnostics here.. + * parser.c (cp_parser_unqualified_id): ..not here. + 2018-04-04 Alexandre Oliva PR c++/84943 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6ddbe2343f4..c8ae72faeae 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8944,6 +8944,13 @@ grokfndecl (tree ctype, warning (0, "floating point suffix %qs" " shadowed by implementation", suffix); } + /* 17.6.3.3.5 */ + if (suffix[0] != '_' + && !in_system_header_at (DECL_SOURCE_LOCATION (decl)) + && !current_function_decl && !(friendp && !funcdef_flag)) + warning (OPT_Wliteral_suffix, + "literal operator suffixes not preceded by %<_%>" + " are reserved for future standardization"); } else { diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d526a4eb365..f6fbcf6185e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6100,16 +6100,6 @@ cp_parser_unqualified_id (cp_parser* parser, /* If that didn't work, try a conversion-function-id. */ if (!cp_parser_parse_definitely (parser)) id = cp_parser_conversion_function_id (parser); - else if (UDLIT_OPER_P (id)) - { - /* 17.6.3.3.5 */ - const char *name = UDLIT_OP_SUFFIX (id); - if (name[0] != '_' && !in_system_header_at (input_location) - && declarator_p) - warning (OPT_Wliteral_suffix, - "literal operator suffixes not preceded by %<_%>" - " are reserved for future standardization"); - } return id; } diff --git a/gcc/testsuite/g++.dg/diagnostic/pr65923.C b/gcc/testsuite/g++.dg/diagnostic/pr65923.C new file mode 100644 index 00000000000..036f4478181 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr65923.C @@ -0,0 +1,23 @@ +// { dg-do compile { target c++14 } } + +#include + +using std::literals::chrono_literals::operator""s; + +struct X +{ + friend constexpr std::chrono::duration std::literals::chrono_literals::operator""s(long double); +}; + +struct X2 +{ + friend constexpr X operator""foo(long double) {return {};} // { dg-warning "literal operator suffixes not preceded" } +}; + +namespace std +{ + template<> void swap(X&, X&) + { + constexpr std::chrono::duration operator""s(long double); + } +} -- 2.30.2