This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to decl_attributes
- To: egcs-patches at cygnus dot com
- Subject: Patch to decl_attributes
- From: Jason Merrill <jason at cygnus dot com>
- Date: Tue, 13 Apr 1999 00:43:58 -0700
I want to add a hook so the C++ frontend can handle its own attributes.
Does this seem like a reasonable strategy?
Tue Apr 13 00:40:53 1999 Jason Merrill <jason@yorick.cygnus.com>
* c-common.c (default_valid_lang_attribute): New fn.
(valid_lang_attribute): New callback ptr.
(decl_attributes): Call it.
Index: c-common.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-common.c,v
retrieving revision 1.55
diff -c -p -r1.55 c-common.c
*** c-common.c 1999/04/09 12:43:24 1.55
--- c-common.c 1999/04/13 07:42:28
*************** c-common.c PROTO
*** 68,73 ****
--- 68,74 ----
int, int));
static void record_international_format PROTO((tree, tree, int));
static tree c_find_base_decl PROTO((tree));
+ static int default_valid_lang_attribute PROTO ((tree, tree, tree, tree));
/* Keep a stack of if statements. We record the number of compound
statements seen up to the if keyword, as well as the line number
*************** init_attributes ()
*** 403,408 ****
--- 404,428 ----
add_attribute (A_NO_CHECK_MEMORY_USAGE, "no_check_memory_usage", 0, 0, 1);
}
+ /* Default implementation of valid_lang_attribute, below. By default, there
+ are no language-specific attributes. */
+
+ static int
+ default_valid_lang_attribute (attr_name, attr_args, decl, type)
+ tree attr_name ATTRIBUTE_UNUSED;
+ tree attr_args ATTRIBUTE_UNUSED;
+ tree decl ATTRIBUTE_UNUSED;
+ tree type ATTRIBUTE_UNUSED;
+ {
+ return 0;
+ }
+
+ /* Return a 1 if ATTR_NAME and ATTR_ARGS denote a valid language-specific
+ attribute for either declaration DECL or type TYPE and 0 otherwise. */
+
+ int (*valid_lang_attribute) PROTO ((tree, tree, tree, tree))
+ = default_valid_lang_attribute;
+
/* Process the attributes listed in ATTRIBUTES and PREFIX_ATTRIBUTES
and install them in NODE, which is either a DECL (including a TYPE_DECL)
or a TYPE. PREFIX_ATTRIBUTES can appear after the declaration specifiers
*************** decl_attributes (node, attributes, prefi
*** 455,461 ****
if (i == attrtab_idx)
{
! if (! valid_machine_attribute (name, args, decl, type))
warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER (name));
else if (decl != 0)
--- 475,482 ----
if (i == attrtab_idx)
{
! if (! valid_machine_attribute (name, args, decl, type)
! && ! valid_lang_attribute (name, args, decl, type))
warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER (name));
else if (decl != 0)