[PATCH] fold more string comparison with known result (PR 90879)

Jakub Jelinek jakub@redhat.com
Fri Aug 9 16:51:00 GMT 2019


On Fri, Aug 09, 2019 at 10:17:12AM -0600, Martin Sebor wrote:
> --- a/gcc/gengtype-state.c
> +++ b/gcc/gengtype-state.c
> @@ -79,6 +79,14 @@ enum state_token_en
>    STOK_NAME                     /* hash-consed name or identifier.  */
>  };
>  
> +/* Suppress warning: ISO C forbids zero-size array for stok_string
> +   below.  The arrays are treated as flexible array members but in
> +   otherwise an empty struct or as a member of a union cannot be
> +   declared as such.  They must have zero size to keep GCC from
> +   assuming their bound reflect their size.  */
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wpedantic"
> +
>  
>  /* Structure and hash-table used to share identifiers or names.  */
>  struct state_ident_st
> @@ -86,11 +94,10 @@ struct state_ident_st
>    /* TODO: We could improve the parser by reserving identifiers for
>       state keywords and adding a keyword number for them.  That would
>       mean adding another field in this state_ident_st struct.  */
> -  char stid_name[1];		/* actually bigger & null terminated */
> +  char stid_name[0];		/* actually bigger & null terminated */

No, please don't do this.  The part of the GCC that is built by system
compiler shouldn't use GNU extensions, unless guarded only for compilation
with compilers that do support that.

	Jakub



More information about the Gcc-patches mailing list