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;
}