This is the mail archive of the 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] Warn for _Alignas in an array declarator (PR c/58267)

On Wed, 16 Oct 2013, Marek Polacek wrote:

> @@ -2946,7 +2957,8 @@ c_parser_declarator (c_parser *parser, b
>        struct c_declspecs *quals_attrs = build_null_declspecs ();
>        struct c_declarator *inner;
>        c_parser_consume_token (parser);
> -      c_parser_declspecs (parser, quals_attrs, false, false, true, cla_prefer_id);
> +      c_parser_declspecs (parser, quals_attrs, false, false, true,
> +			  true, cla_prefer_id);
>        inner = c_parser_declarator (parser, type_seen_p, kind, seen_id);
>        if (inner == NULL)
>  	return NULL;

Looking at this again, shouldn't the new argument be "false" (with 
associated testcase)?  This is parsing pointer declarators, and _Alignas 
isn't allowed there any more than it is in array declarators....

> @@ -3715,7 +3730,8 @@ c_parser_type_name (c_parser *parser)
>    struct c_declarator *declarator;
>    struct c_type_name *ret;
>    bool dummy = false;
> -  c_parser_declspecs (parser, specs, false, true, true, cla_prefer_type);
> +  c_parser_declspecs (parser, specs, false, true, true, false,
> +		      cla_prefer_type);
>    if (!specs->declspecs_seen_p)
>      {
>        c_parser_error (parser, "expected specifier-qualifier-list");

And this should get a testcase added, that _Alignas is correctly rejected 
in type names where previously it would have been wrongly accepted.

(Strictly by the standard it should be "false" in 
c_parser_struct_declaration as well - the syntax there doesn't allow 
_Alignas - but it appears to have been intended to allow it there, so 
probably best not to change anything there until WG14 reaches a conclusion 
on the issues I raised in N1731.)

Joseph S. Myers

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