public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109653] New: [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13
@ 2023-04-27 19:37 gcc-bugs at aitchison dot me.uk
  2023-04-27 19:49 ` [Bug c++/109653] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gcc-bugs at aitchison dot me.uk @ 2023-04-27 19:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109653

            Bug ID: 109653
           Summary: [[clang::fallthrough]] recognised up to g++ v12 not
                    not g++ v13
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at aitchison dot me.uk
  Target Milestone: ---

Created attachment 54945
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54945&action=edit
Test alternate spelling clang::fallthrough

g++ v12 and earlier ignore the line
    [[clang::fallthrough]];
but v13 complains:
warning: attributes at the beginning of statement are ignored [-Wattributes]

This is a common alternative spelling of
  [[gnu::fallthrough]];
and
  [[fallthrough]];
so it is a pity that when g++ supports the feature in its default mode (ie
without specifying  a --std) it starts objecting to code which on some other
compilers enables the functionality.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/109653] [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13
  2023-04-27 19:37 [Bug c++/109653] New: [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13 gcc-bugs at aitchison dot me.uk
@ 2023-04-27 19:49 ` redi at gcc dot gnu.org
  2023-04-27 19:55 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-27 19:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109653

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The warning started with r13-3149
"c++: Improve handling of foreigner namespace attributes"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/109653] [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13
  2023-04-27 19:37 [Bug c++/109653] New: [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13 gcc-bugs at aitchison dot me.uk
  2023-04-27 19:49 ` [Bug c++/109653] " redi at gcc dot gnu.org
@ 2023-04-27 19:55 ` pinskia at gcc dot gnu.org
  2023-04-27 20:00 ` pinskia at gcc dot gnu.org
  2023-04-27 20:18 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-27 19:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109653

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, __has_cpp_attribute never returns 0 for unknown attributes

#if defined __has_cpp_attribute 
#  if __has_cpp_attribute (fakeattribute)
#    error errorout
#  endif
#endif

I thought it should.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/109653] [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13
  2023-04-27 19:37 [Bug c++/109653] New: [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13 gcc-bugs at aitchison dot me.uk
  2023-04-27 19:49 ` [Bug c++/109653] " redi at gcc dot gnu.org
  2023-04-27 19:55 ` pinskia at gcc dot gnu.org
@ 2023-04-27 20:00 ` pinskia at gcc dot gnu.org
  2023-04-27 20:18 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-27 20:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109653

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Hmm, __has_cpp_attribute never returns 0 for unknown attributes
> 
> #if defined __has_cpp_attribute 
> #  if __has_cpp_attribute (fakeattribute)
> #    error errorout
> #  endif
> #endif
> 
> I thought it should.

Never mind, it does.

This is how you are supposed to use attributes:
#if defined __has_cpp_attribute 
#  if __has_cpp_attribute (clang::fallthrough)
#   define f [[clang::fallthrough]]
#  elif __has_cpp_attribute (gnu::fallthrough)
#   define f [[gnu::fallthrough]]
#  elif  __has_cpp_attribute (fallthrough)
#   define f [[fallthrough]]
# endif
#endif

#ifndef f
#define f
#endif


#include <cstdio>

int main (int argc, char* argv[])
{
    switch(argc)
    {
    case 0:
        printf("%s\n", argv[1]);
        f;
    default:
        printf("%d args\n", argc);
    }

    return 0;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/109653] [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13
  2023-04-27 19:37 [Bug c++/109653] New: [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13 gcc-bugs at aitchison dot me.uk
                   ` (2 preceding siblings ...)
  2023-04-27 20:00 ` pinskia at gcc dot gnu.org
@ 2023-04-27 20:18 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-27 20:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109653

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That change was completely intentional, previously for some of the well known
attribute names from random other namespaces we were handling them like the gnu
or standard ones, which is obviously wrong, we don't really know anything about
some other vendor wants to treat them.
Generally, one can use e.g. -Wno-attributes=clang:: to avoid warnings about
clang:: namespace attributes, but in this case it warns anyway.  Maybe we
should filter away the -Wno-attributes= in the statement cases as well, rather
than just in the more usual attribute spots.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-27 20:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 19:37 [Bug c++/109653] New: [[clang::fallthrough]] recognised up to g++ v12 not not g++ v13 gcc-bugs at aitchison dot me.uk
2023-04-27 19:49 ` [Bug c++/109653] " redi at gcc dot gnu.org
2023-04-27 19:55 ` pinskia at gcc dot gnu.org
2023-04-27 20:00 ` pinskia at gcc dot gnu.org
2023-04-27 20:18 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).