[PATCH] add __attribute__ ((designated_init))

Joseph S. Myers joseph@codesourcery.com
Fri Jan 24 17:07:00 GMT 2014


On Thu, 23 Jan 2014, Tom Tromey wrote:

> In this error, should I use "%<struct%>" rather than just plain "struct"
> as well?

I think that's best (generally, %<%> or %q with anything quoting a 
source-code construct - anything that would go in a fixed-width font in 
documentation - "struct" is such a case, the English word is "structure").

> +  if (!implicit && warn_designated_init && !was_designated
> +      && TREE_CODE (constructor_type) == RECORD_TYPE
> +      && lookup_attribute ("designated_init",
> +			   TYPE_ATTRIBUTES (constructor_type)))
> +    warning_init (OPT_Wdesignated_init,
> +		  "positional initialization of field "
> +		  "in struct declared with designated_init attribute");

Also %<struct%> and %<designated_init%> here.

> +@item designated_init
> +This attribute may only be applied to struct types.  It indicates that

And @code{struct} (or "structure") here.

Is there a reason someone using the attribute might not want the warning?  
That is, why isn't -Wdesignated-init enabled by default, given that it's 
only relevant to people using an attribute whose sole function relates to 
the warning?

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list