This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[C++] Attributes and explicit template instantiations
- From: Matt Austern <austern at apple dot com>
- To: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Fri, 5 Nov 2004 12:14:35 -0800
- Subject: [C++] Attributes and explicit template instantiations
The C++ parser allows the following:
template __attribute__ ((visibility("hidden"))) void xyzzy<int>() ;
However, the visibility attribute is ignored.
As far as I can tell from looking at parser.c, this has nothing to do
with visibility; it's just a quirk in attribute handling that nobody
seems to have thought much about. Possibly I'm missing something, but
what it looks like to me is that cp_parser_explicit_instantiation
accepts the __attribute__ list almost by accident, because it calls
cp_parser_decl_specifier_seq, and the GNU compiler always considers an
attribute to be a decl specifier, but that it doesn't ever do anything
with any attributes it collects.
So we've got the same question as before: is the bug that we're
throwing away the attributes instead of applying them to the template
instantiation, or is the bug that we accept attributes here at all?
Silently ignoring them is clearly wrong; we should either apply them or
give a diagnostic. I have a slight preference for the former, but I
could live with either.
--Matt