On 3/18/25 4:08 AM, Jakub Jelinek wrote:
On Mon, Mar 17, 2025 at 09:41:49AM -0400, Jason Merrill wrote:
On 3/13/25 4:10 PM, Jakub Jelinek wrote:
I know, but we've never allowed GNU attributes on most of those, neither
does clang, we don't allow it in C and with the exception of
fallthrough/assume on empty statement and musttail on return we currently
even don't have any uses for it.  If we start accepting it, we'd then
need to support it forever.

But, as you say, we already started accepting it for
fallthrough/assume/musttail; deciding to allow it in that case and not in
others seems weirdly inconsistent.

Well, we started allowing just
  [[]] __attribute__((assume (true)));
or
  [[assume (true)]] __attribute__(());
and not random mixes.  Anyway, below is a patch which accepts all kinds of
ordering and mixing of standard and GNU attributes at the start of
statements (for C++)

Bootstraps/regtests (on x86_64-linux and i686-linux) found a regression
on attr-fallthrough-2.c, we no longer for C++
attr-fallthrough-2.c:24:3: error: expected primary-expression before 'case'
but
attr-fallthrough-2.c:24:9: warning: 'fallthrough' attribute ignored 
[-Wattributes]

So, becoming consistent with the [[fallthrough]] spelling? That seems like an improvement. I see we also give the more informative "'fallthrough' attribute not followed by ';'" diagnostic.

So in an init-statement we can use GNU attributes but not standard
attributes?  Another strange inconsistency.

True, but it is not allowed to have there standard attributes and am not
sure if we should reject what we started accepting in GCC 13.

I've now asked CWG about adding standard attributes there. It seems useful to support [[assume]] in that location (as in ext/pr116545.C).

Here is updated patch which adjusts that testcase.

The C++ changes are OK.

Jason

Reply via email to