This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Change handling of common attributes
- To: gcc-patches at gcc dot gnu dot org
- Subject: Change handling of common attributes
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Sat, 22 Sep 01 09:25:35 EDT
GNAT used valid_machine_attribute, which was in tree.c, but now the attribute
handling is in c-common.c, which it can't use. So I moved all the attribute
handling (except for "format", which was already in its own file,
c-format.c), to a new file, attribs.c. I had to eliminate a test against
uintmax for the "mode" attribute since it isn't language-independent, but
it's a somewhat dubious test anyway since we already check for a mode too
large. I also split off the "format" attributes and allowed a language to
say that it doesn't want the common attributes either (so it gets only those
defined by the target).
Tested on alphaev56.
In the diff below, I didn't include the new file or the hunk in c-common.c
that deletes the part moved into the file.
Sat Sep 22 09:09:32 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* attribs.c: New file, from c-common.c.
(attribute_tables): Now four elements.
(format_attribute_table, lang_attribute_common): New variables.
(init_attributes): Reflect above changes.
(handle_mode_attribute): Delete check for wider than uintmax.
* c-common.c: Delete parts moved to attribs.c.
(enum attrs): Deleted; unused.
(c_format_attribute_table): New variable.
(c_common_lang_init): Initialize format_attribute_table with it.
* c-common.h (decl_attributes): Remove decl.
* tree.h (decl_attribute): Move it to here.
* Makefile.in (C_AND_OBJS_OBJS): Add attribs.o.
(attribs.o): New rule.
* ch/Make-lang.in (cc1chill): Add attribs.o.
* cp/Make-lang.in (CXX_C_OBJS): Add attribs.o.
*** c-common.c 2001/09/21 15:08:52 1.253
--- c-common.c 2001/09/22 12:57:11
*************** void (*back_end_hook) PARAMS ((tree));
*** 217,226 ****
int skip_evaluation;
- enum attrs {A_PACKED, A_NOCOMMON, A_COMMON, A_NORETURN, A_CONST, A_T_UNION,
- A_NO_CHECK_MEMORY_USAGE, A_NO_INSTRUMENT_FUNCTION,
- A_CONSTRUCTOR, A_DESTRUCTOR, A_MODE, A_SECTION, A_ALIGNED,
- A_UNUSED, A_FORMAT, A_FORMAT_ARG, A_WEAK, A_ALIAS, A_MALLOC,
- A_NO_LIMIT_STACK, A_PURE};
-
/* Information about how a function name is generated. */
struct fname_var_t
--- 217,220 ----
*************** boolean_increment (code, arg)
*** 4918,4926 ****
--- 3773,3796 ----
}
+ /* Give the specifications for the format attributes, used by C and all
+ descendents. */
+ static const struct attribute_spec c_format_attribute_table[] =
+ {
+ { "format", 3, 3, true, false, false,
+ handle_format_attribute },
+ { "format_arg", 1, 1, true, false, false,
+ handle_format_arg_attribute },
+ { NULL, 0, 0, false, false, false, NULL }
+ };
+
+ extern const struct attribute_spec *format_attribute_table;
+
/* Do the parts of lang_init common to C and C++. */
void
c_common_lang_init ()
{
+ format_attribute_table = c_format_attribute_table;
+
/* If still "unspecified", make it match -fbounded-pointers. */
if (flag_bounds_check < 0)
*** c-common.h 2001/09/21 01:26:51 1.84
--- c-common.h 2001/09/22 12:57:13
*************** extern tree fname_decl PARAMS ((unsig
*** 504,508 ****
extern const char *fname_string PARAMS ((unsigned));
- extern tree decl_attributes PARAMS ((tree *, tree, int));
extern void init_function_format_info PARAMS ((void));
extern void check_function_format PARAMS ((int *, tree, tree, tree));
--- 504,507 ----
*** tree.h 2001/09/21 15:58:35 1.266
--- tree.h 2001/09/22 12:57:43
*************** extern rtx emit_line_note PARAMS ((cons
*** 2907,2910 ****
--- 2907,2913 ----
extern int setjmp_call_p PARAMS ((tree));
+ /* In attribs.c. */
+ extern tree decl_attributes PARAMS ((tree *, tree, int));
+
/* In front end. */
*** Makefile.in 2001/09/21 01:26:51 1.737
--- Makefile.in 2001/09/22 12:56:39
*************** CXX_TARGET_OBJS=@cxx_target_objs@
*** 723,727 ****
# Language-specific object files for C and Objective C.
! C_AND_OBJC_OBJS = c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
c-convert.o c-aux-info.o c-common.o c-format.o c-semantics.o c-dump.o \
libcpp.a $(C_TARGET_OBJS)
--- 723,727 ----
# Language-specific object files for C and Objective C.
! C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
c-convert.o c-aux-info.o c-common.o c-format.o c-semantics.o c-dump.o \
libcpp.a $(C_TARGET_OBJS)
*************** c-common.o : c-common.c $(CONFIG_H) $(SY
*** 1250,1253 ****
--- 1250,1259 ----
$(C_COMMON_H) flags.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
$(EXPR_H) $(TM_P_H) builtin-types.def $(TARGET_H)
+
+ # A file used by all variants of C and some other languages.
+
+ attribs.o : attribs.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(OBSTACK_H) flags.h \
+ toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) $(EXPR_H) $(TM_P_H) \
+ builtin-types.def $(TARGET_H)
c-format.o : c-format.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
*** ch/Make-lang.in 2001/05/27 17:07:17 1.22
--- ch/Make-lang.in 2001/09/22 12:57:58
*************** chill-cross: $(srcdir)/ch/chill.in
*** 96,100 ****
cc1chill$(exeext): $(P) $(CHILL_SRCS) $(LIBDEPS) $(BACKEND) \
insn-config.h insn-flags.h insn-attr.h insn-codes.h \
! c-typeck.o c-aux-info.o c-common.o \
ggc-callbacks.o
cd ch; $(MAKE) $(LANG_FLAGS_TO_PASS) $(CHILL_FLAGS_TO_PASS) ../cc1chill$(exeext)
--- 96,100 ----
cc1chill$(exeext): $(P) $(CHILL_SRCS) $(LIBDEPS) $(BACKEND) \
insn-config.h insn-flags.h insn-attr.h insn-codes.h \
! attribs.o c-typeck.o c-aux-info.o c-common.o \
ggc-callbacks.o
cd ch; $(MAKE) $(LANG_FLAGS_TO_PASS) $(CHILL_FLAGS_TO_PASS) ../cc1chill$(exeext)
*** cp/Make-lang.in 2001/09/15 19:47:34 1.90
--- cp/Make-lang.in 2001/09/22 12:58:09
*************** $(DEMANGLER_PROG): cxxmain.o underscore.
*** 94,98 ****
# The compiler itself.
# Shared with C front end:
! CXX_C_OBJS = c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o c-dump.o $(CXX_TARGET_OBJS)
# Language-specific object files.
--- 94,99 ----
# The compiler itself.
# Shared with C front end:
! CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \
! c-dump.o $(CXX_TARGET_OBJS)
# Language-specific object files.