This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Cases of attributes
- To: <gcc at gcc dot gnu dot org>
- Subject: Cases of attributes
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Tue, 10 Jul 2001 22:01:58 +0100 (BST)
As mentioned in <URL:http://gcc.gnu.org/ml/gcc/2001-07/msg00129.html> and
<URL:http://gcc.gnu.org/ml/gcc/2001-07/msg00259.html> I propose to change
attribute handling (as in decl_attributes) to be driven by tables of known
attributes and function pointers to handle them.
I believe that there are three distinct cases in which attributes are
applied:
* To a declaration (which might in turn affect the type of the
declaration).
* To a struct/union/enum type that is in the process of being created (for
example, "packed"), which should be modified in place.
* To a type that is part of a declaration (possibly a typedef), where a
copy of the type needs to be created rather than the type itself being
modified (for example, "noreturn" ought to work this way).
Some corresponding questions:
* Do other people agree with this analysis?
* Should there be the single entry point decl_attributes for handling all
three cases (which would then need an additional parameter saying which
case applied when a type is passed - and would return the new type in the
third case), or should there be separate entry points for the separate
cases?
* Does the distinction between the second and third cases need preserving,
or would it suffice simply to copy the type whenever applying an
attribute? (The code should of course check for unsupported cases - at
present, "packed" attributes on typedefs for structures appear to get
silently ignored, as the structure has already been laid out.)
--
Joseph S. Myers
jsm28@cam.ac.uk