On 08/24/2018 01:52 PM, Bernd Edlinger wrote:
> Hi,
> 
> this updated patch fixes one regression with current trunk due
> to a new test case.  Sorry for the confusion.
> 
> The change to the previous version is:
> 1) the check to avoid folding on empty char arrays is restored.
> 2) A null-termination character is added except when the string is full 
> length.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.
> 
> 
> patch-bracedstr-v2.diff
> 
> 
> c-family:
> 2018-08-24  Bernd Edlinger  <bernd.edlin...@hotmail.de>
> 
>       * c-common.c (braced_list_to_string): Remove eval parameter.
>       Add some more checks.  Always create zero-terminated STRING_CST.
>       * c-common.h (braced_list_to_string): Adjust prototype.
> 
> c:
> 2018-08-24  Bernd Edlinger  <bernd.edlin...@hotmail.de>
> 
>       * c-decl.c (finish_decl): Call braced_list_to_string here ...
>       * c-parser.c (c_parser_declaration_or_fndef): ... instead of here.
> 
> 
> cp:
> 2018-08-24  Bernd Edlinger  <bernd.edlin...@hotmail.de>
> 
>       * decl.c (eval_check_narrowing): Remove.
>       (check_initializer): Move call to braced_list_to_string from here ...
>       * typeck2.c (store_init_value): ... to here.
>       (digest_init_r): Remove handing of signed/unsigned char strings.
> 
> testsuite:
> 2018-08-24  Bernd Edlinger  <bernd.edlin...@hotmail.de>
> 
>       * c-c++-common/array-init.c: New test.
>       * g++.dg/init/string2.C: Remove xfail.
My concern here is that you removed code that was explicitly added
during the initial review work of the patch that turned braced
initializers into strings.


> -    a[] = { 1, 2, 333, 0 };         // { dg-warning 
> "\\\[\(-Wnarrowing|-Woverflow\)" "" { target { ! c++98_only } } }
> +    a[] = { 1, 2, 333, 0 };         // { dg-warning 
> "\\\[\(-Wnarrowing|-Woverflow\)" }
This is not an XFAIL, this is a selector.  Essentially it says that the
diagnostic is appropriate when not in c++98 mode.

You can see that to be the case if you compile the test in c++98 mode
without your change.  It will compile with no errors or warnings.

However, after your change it issues a warning for the narrowing
conversion in c++98 mode, which AFAICT it should not do.

jeff





Reply via email to