PATCH: Updated error messages for ill-formed cases of array initialization by string literal

Tom Honermann tom@honermann.net
Thu Dec 27 21:29:00 GMT 2018


As requested by Jason in the review of the P0482 (char8_t) core language 
changes, this patch includes updates to the error messages emitted for 
ill-formed cases of array initialization with a string literal.  With 
these changes, error messages that previously looked something like these:

- "char-array initialized from wide string"
- "wide character array initialized from non-wide string"
- "wide character array initialized from incompatible wide string"

now look like:

- "cannot initialize array of type 'char' from a string literal with 
type array of 'short unsigned int'"
- "cannot initialize array of type 'short unsigned int' from a string 
literal with type array of 'char'"
- "cannot initialize array of type 'short unsigned int' from a string 
literal with type array of 'unsigned int'"

These changes affect both the C and C++ front ends.

These changes have dependencies on the (revised) set of patches 
submitted for P0482 (char8_t) and will not apply cleanly without them.

Tested on x86_64-linux.

gcc/c/ChangeLog:

2018-12-26  Tom Honermann  <tom@honermann.net>

      * c-typeck.c (digest_init): Revised the error message produced for
      ill-formed cases of array initialization with a string literal.

gcc/cp/ChangeLog:

2018-12-26  Tom Honermann  <tom@honermann.net>

      * typeck2.c (digest_init_r): Revised the error message produced for
      ill-formed cases of array initialization with a string literal.

gcc/testsuite/ChangeLog:

2018-12-26  Tom Honermann  <tom@honermann.net>

      * gcc/testsuite/g++.dg/ext/char8_t-init-2.C: Updated the expected
      error messages for ill-formed cases of array initialization with a
      string literal.
      * gcc/testsuite/g++.dg/ext/utf-array-short-wchar.C: Likewise.
      * gcc/testsuite/g++.dg/ext/utf-array.C: Likewise.
      * gcc/testsuite/g++.dg/ext/utf8-2.C: Likewise.
      * gcc/testsuite/gcc.dg/init-string-2.c: Likewise.
      * gcc/testsuite/gcc.dg/pr61096-1.c: Likewise.
      * gcc/testsuite/gcc.dg/utf-array-short-wchar.c: Likewise.
      * gcc/testsuite/gcc.dg/utf-array.c: Likewise.
      * gcc/testsuite/gcc.dg/utf8-2.c: Likewise.

Tom.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: array-init-error-msg.patch
Type: text/x-patch
Size: 25529 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20181227/641bcc8a/attachment.bin>


More information about the Gcc-patches mailing list