diff options
author | Andrea Azzarone <azzaronea@gmail.com> | 2015-02-12 20:21:34 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-02-12 15:21:34 -0500 |
commit | bc81eb3f77b27d46e25c218cfd9f32c89cc36b3c (patch) | |
tree | 9e8f65f24d3a49b152bf5bb8ea477528a1d4764e /gcc/cp | |
parent | 864f0146f052c560b81794aced67f5d095d241a3 (diff) | |
download | gcc-bc81eb3f77b27d46e25c218cfd9f32c89cc36b3c.zip gcc-bc81eb3f77b27d46e25c218cfd9f32c89cc36b3c.tar.gz gcc-bc81eb3f77b27d46e25c218cfd9f32c89cc36b3c.tar.bz2 |
re PR c++/64959 (SFINAE in UDLs)
PR c++/64959
* parser.c (lookup_literal_operator): Return all candidates.
(cp_parser_userdef_char_literal): Simplify error handling.
(cp_parser_userdef_numeric_literal): Pass tf_warning_or_error.
(cp_parser_userdef_string_literal): Pass tf_warning_or_error.
Also give higher priority to standard string UDL operator.
From-SVN: r220656
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/parser.c | 107 |
2 files changed, 58 insertions, 58 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 722e926..e460c55 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2015-02-12 Andrea Azzarone <azzaronea@gmail.com> + + PR c++/64959 + * parser.c (lookup_literal_operator): Return all candidates. + (cp_parser_userdef_char_literal): Simplify error handling. + (cp_parser_userdef_numeric_literal): Pass tf_warning_or_error. + (cp_parser_userdef_string_literal): Pass tf_warning_or_error. + Also give higher priority to standard string UDL operator. + 2015-02-12 Jakub Jelinek <jakub@redhat.com> PR debug/55541 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 57dfbcc..e81e9d3 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3828,7 +3828,7 @@ lookup_literal_operator (tree name, vec<tree, va_gc> *args) work in presence of default arguments on the literal operator parameters. */ && parmtypes == void_list_node) - return fn; + return decl; } } @@ -3862,12 +3862,7 @@ cp_parser_userdef_char_literal (cp_parser *parser) } result = finish_call_expr (decl, &args, false, true, tf_warning_or_error); release_tree_vector (args); - if (result != error_mark_node) - return result; - - error ("unable to find character literal operator %qD with %qT argument", - name, TREE_TYPE (value)); - return error_mark_node; + return result; } /* A subroutine of cp_parser_userdef_numeric_literal to @@ -3955,26 +3950,28 @@ cp_parser_userdef_numeric_literal (cp_parser *parser) decl = lookup_literal_operator (name, args); if (decl && decl != error_mark_node) { - result = finish_call_expr (decl, &args, false, true, tf_none); - if (result != error_mark_node) + result = finish_call_expr (decl, &args, false, true, + tf_warning_or_error); + + if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE && overflow > 0) + { + warning_at (token->location, OPT_Woverflow, + "integer literal exceeds range of %qT type", + long_long_unsigned_type_node); + } + else { - if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE && overflow > 0) + if (overflow > 0) warning_at (token->location, OPT_Woverflow, - "integer literal exceeds range of %qT type", - long_long_unsigned_type_node); - else - { - if (overflow > 0) - warning_at (token->location, OPT_Woverflow, - "floating literal exceeds range of %qT type", - long_double_type_node); - else if (overflow < 0) - warning_at (token->location, OPT_Woverflow, - "floating literal truncated to zero"); - } - release_tree_vector (args); - return result; + "floating literal exceeds range of %qT type", + long_double_type_node); + else if (overflow < 0) + warning_at (token->location, OPT_Woverflow, + "floating literal truncated to zero"); } + + release_tree_vector (args); + return result; } release_tree_vector (args); @@ -3986,12 +3983,10 @@ cp_parser_userdef_numeric_literal (cp_parser *parser) decl = lookup_literal_operator (name, args); if (decl && decl != error_mark_node) { - result = finish_call_expr (decl, &args, false, true, tf_none); - if (result != error_mark_node) - { - release_tree_vector (args); - return result; - } + result = finish_call_expr (decl, &args, false, true, + tf_warning_or_error); + release_tree_vector (args); + return result; } release_tree_vector (args); @@ -4004,13 +3999,12 @@ cp_parser_userdef_numeric_literal (cp_parser *parser) { tree tmpl_args = make_char_string_pack (num_string); decl = lookup_template_function (decl, tmpl_args); - result = finish_call_expr (decl, &args, false, true, tf_none); - if (result != error_mark_node) - { - release_tree_vector (args); - return result; - } + result = finish_call_expr (decl, &args, false, true, + tf_warning_or_error); + release_tree_vector (args); + return result; } + release_tree_vector (args); error ("unable to find numeric literal operator %qD", name); @@ -4035,40 +4029,37 @@ cp_parser_userdef_string_literal (tree literal) tree decl, result; vec<tree, va_gc> *args; - /* Look for a template function with typename parameter CharT - and parameter pack CharT... Call the function with - template parameter characters representing the string. */ + /* Build up a call to the user-defined operator. */ + /* Lookup the name we got back from the id-expression. */ args = make_tree_vector (); + vec_safe_push (args, value); + vec_safe_push (args, build_int_cst (size_type_node, len)); decl = lookup_literal_operator (name, args); + if (decl && decl != error_mark_node) { - tree tmpl_args = make_string_pack (value); - decl = lookup_template_function (decl, tmpl_args); - result = finish_call_expr (decl, &args, false, true, tf_none); - if (result != error_mark_node) - { - release_tree_vector (args); - return result; - } + result = finish_call_expr (decl, &args, false, true, + tf_warning_or_error); + release_tree_vector (args); + return result; } release_tree_vector (args); - /* Build up a call to the user-defined operator */ - /* Lookup the name we got back from the id-expression. */ + /* Look for a template function with typename parameter CharT + and parameter pack CharT... Call the function with + template parameter characters representing the string. */ args = make_tree_vector (); - vec_safe_push (args, value); - vec_safe_push (args, build_int_cst (size_type_node, len)); - decl = lookup_name (name); - if (!decl || decl == error_mark_node) + decl = lookup_literal_operator (name, args); + if (decl && decl != error_mark_node) { - error ("unable to find string literal operator %qD", name); + tree tmpl_args = make_string_pack (value); + decl = lookup_template_function (decl, tmpl_args); + result = finish_call_expr (decl, &args, false, true, + tf_warning_or_error); release_tree_vector (args); - return error_mark_node; + return result; } - result = finish_call_expr (decl, &args, false, true, tf_none); release_tree_vector (args); - if (result != error_mark_node) - return result; error ("unable to find string literal operator %qD with %qT, %qT arguments", name, TREE_TYPE (value), size_type_node); |