Libstdc++ can't use C++11 attribute syntax for GNU-specific attributes like [[gnu::nonnull]], because those identifiers are not reserved names. We can use __nonnull__ but only "gnu" is recognized for the namespace. Could G++ be extended to also accept [[__gnu__::__nonnull__]] ? __gnu__ doesn't seem to clash with anything predefined by GCC, or defined by Glibc.
Unrelated note, we even ICE on int f [[using gnu : __aligned__(alignof(int))]];
Created attachment 44846 [details] gcc9-pr86288.patch Untested patch with implementation for this enhancement request as well as fix for the above mentioned ICE (the latter should be backported I guess).
If both __gnu__ and __gnu are accepted, should both __aligned__ and __aligned also be? If not, then should only __gnu__ be accepted?
I think Jakub's patch does only allow __gnu__, using the same canonicalization for attribute-namespaces as for attributes.
Clang has now implemented this as a special case, only recognizing "__gnu__" as a synonym for the "gnu" attribute-namespace. That's fine for libstdc++'s purposes, as I don't expect we'll start using any other vendor attributes. EDG have also been told about this, so compilers based on their front end should also be able to recognize [[__gnu__::__blah__]] at some point.
Author: jakub Date: Wed Oct 24 19:39:23 2018 New Revision: 265470 URL: https://gcc.gnu.org/viewcvs?rev=265470&root=gcc&view=rev Log: PR c++/86288 * parser.c (cp_parser_std_attribute): Canonicalize attr_ns, and when :: is not present and attr_ns non-NULL, canonicalize also attr_id. (cp_parser_attribute_spec): Fix comment typo. * g++.dg/cpp0x/gen-attrs-66.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/gen-attrs-66.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Mon Nov 5 14:09:10 2018 New Revision: 265803 URL: https://gcc.gnu.org/viewcvs?rev=265803&root=gcc&view=rev Log: Backported from mainline 2018-10-24 Jakub Jelinek <jakub@redhat.com> PR c++/86288 * parser.c (cp_parser_std_attribute): Canonicalize attr_ns, and when :: is not present and attr_ns non-NULL, canonicalize also attr_id. (cp_parser_attribute_spec): Fix comment typo. * g++.dg/cpp0x/gen-attrs-66.C: New test. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp0x/gen-attrs-66.C Modified: branches/gcc-8-branch/gcc/cp/ChangeLog branches/gcc-8-branch/gcc/cp/parser.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
Fixed for 8.3 and 9.1