OSDN Git Service

PR c++/50976
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Nov 2011 16:51:41 +0000 (16:51 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Nov 2011 16:51:41 +0000 (16:51 +0000)
* typeck.c (check_literal_operator_args): Reorganize test for string
operators so size_t search depends on finding string first.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181292 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck.c

index 9568030..291487f 100644 (file)
@@ -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  <jason@redhat.com>
 
        PR c++/50372
index 2964952..722cec5 100644 (file)
@@ -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;
     }
 }