From f05eec4a0d41f9b9b5ef0131407581c5edb6f79c Mon Sep 17 00:00:00 2001 From: Ed Smith-Rowland <3dw4rd@verizon.net> Date: Fri, 11 Nov 2011 16:51:41 +0000 Subject: re PR c++/50976 ([C++0x] literal operator with unsigned long long parameter not accepted) PR c++/50976 * typeck.c (check_literal_operator_args): Reorganize test for string operators so size_t search depends on finding string first. From-SVN: r181292 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 41 ++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9568030..291487f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-11-11 Ed Smith-Rowland <3dw4rd@verizon.net> + + PR c++/50976 + * typeck.c (check_literal_operator_args): Reorganize test for string + operators so size_t search depends on finding string first. + 2011-11-10 Jason Merrill PR c++/50372 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 2964952..722cec5 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -8425,9 +8425,6 @@ check_literal_operator_args (const_tree decl, tree argtype; int arity; int max_arity = 2; - bool found_string_p = false; - bool maybe_raw_p = false; - bool found_size_p = false; *long_long_unsigned_p = false; *long_double_p = false; @@ -8442,29 +8439,30 @@ check_literal_operator_args (const_tree decl, if (TREE_CODE (t) == POINTER_TYPE) { + bool maybe_raw_p = false; t = TREE_TYPE (t); if (cp_type_quals (t) != TYPE_QUAL_CONST) return false; t = TYPE_MAIN_VARIANT (t); - if (same_type_p (t, char_type_node)) + if ((maybe_raw_p = same_type_p (t, char_type_node)) + || same_type_p (t, wchar_type_node) + || same_type_p (t, char16_type_node) + || same_type_p (t, char32_type_node)) { - found_string_p = true; - maybe_raw_p = true; + argtype = TREE_CHAIN (argtype); + if (!argtype) + return false; + t = TREE_VALUE (argtype); + if (maybe_raw_p && argtype == void_list_node) + return true; + else if (same_type_p (t, size_type_node)) + { + ++arity; + continue; + } + else + return false; } - else if (same_type_p (t, wchar_type_node)) - found_string_p = true; - else if (same_type_p (t, char16_type_node)) - found_string_p = true; - else if (same_type_p (t, char32_type_node)) - found_string_p = true; - else - return false; - } - else if (same_type_p (t, size_type_node)) - { - if (!found_string_p) - return false; - found_size_p = true; } else if (same_type_p (t, long_long_unsigned_type_node)) { @@ -8493,9 +8491,6 @@ check_literal_operator_args (const_tree decl, if (arity > max_arity) return false; - if (found_string_p && !maybe_raw_p && !found_size_p) - return false; - return true; } } -- cgit v1.1