This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch] PR 43453


On 05/26/2014 11:41 AM, Paolo Carlini wrote:
+      /* C++11 8.5/17: "If the destination type is an array of characters,
+	 an array of char16_t, an array of char32_t, or an array of wchar_t,
+	 and the initializer is a string literal...".  */
+      else if (TREE_CODE (newrhs) == STRING_CST
+	       && char_type_p (TREE_TYPE (TYPE_MAIN_VARIANT (lhstype)))
+	       && modifycode == INIT_EXPR)
+	{
+	  newrhs = digest_init (lhstype, newrhs, complain);
+	  if (newrhs == error_mark_node)
+	    return error_mark_node;
+	}

This hunk is OK.

       if (TREE_CODE (init) == TREE_LIST
-	       && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+	  && TREE_CODE (type) == ARRAY_TYPE
+	  /* C++11 8.5/17: "If the destination type is an array of characters,
+	     an array of char16_t, an array of char32_t, or an array of wchar_t,
+	     and the initializer is a string literal...".  */
+	  && !(char_type_p (TREE_TYPE (TYPE_MAIN_VARIANT (type)))
+	       && TREE_CODE (TREE_VALUE (init)) == STRING_CST))
 	{
 	  error ("cannot initialize arrays using this syntax");
 	  return NULL_TREE;

Can we just remove this error rather than add a condition? I think it's covered in other places.

The patch doesn't seem to fix

  char s[] ("foo");

which I think also ought to be well-formed.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]