diff options
author | Ville Voutilainen <ville.voutilainen@gmail.com> | 2018-04-04 16:05:11 +0000 |
---|---|---|
committer | Ville Voutilainen <ville.voutilainen@gmail.com> | 2018-04-04 16:05:11 +0000 |
commit | 32286c0f1331290e10ed009a9691a7b295ad4a6d (patch) | |
tree | 03988e369911dc89da55b85ccb1708683aed4a4b | |
parent | a5db26fed43927d0ceae7bd9df1047862d818306 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@259087 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/diagnostic/pr65923.C | 23 |
4 files changed, 36 insertions, 10 deletions
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 <ville.voutilainen@gmail.com> + + PR c++/65923 + * decl.c (grokfndecl): Handle standard UDL diagnostics here.. + * parser.c (cp_parser_unqualified_id): ..not here. + 2018-04-04 Alexandre Oliva <aoliva@redhat.com> 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 <chrono> + +using std::literals::chrono_literals::operator""s; + +struct X +{ + friend constexpr std::chrono::duration<long double> 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<long double> operator""s(long double); + } +} |