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


Hi,

On 06/04/2014 04:16 PM, Jason Merrill wrote:
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.
Removing it certainly passes testing.
The patch doesn't seem to fix

  char s[] ("foo");

which I think also ought to be well-formed.
Right. Thus I reworked a bit the code in cp_complete_array_type to handle specially a single-element TREE_LIST together a single-element CONSTRUCTOR. Tested x86_64-linux.

Thanks!
Paolo.

//////////////////

Attachment: CL_43453_2
Description: Text document

Attachment: patch_43453_2
Description: Text document


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