system.h & warnings (patch for gansidecl.h included)
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Sat Apr 4 14:20:00 GMT 1998
> From: Jeffrey A Law <law@hurl.cygnus.com>
> Status: RO
>
>
> In message < 199804021620.LAA18789@caip.rutgers.edu >you write:
> > One thing I'd like to bring up, the test you used in genoutput.c
> > to see if __attribute__ should be used only checks __GNUC__. This can
> > fail for stage1 compilers which are gcc but are older versions. E.g.
> > these can be either gcc installed by the user or the default compiler
> > (like maybe nextstep? I'll bet it fails there.)
> Good point.
>
>
> > I'd like to put something in gansidecl.h to do a rigorous test
> > once. Then one can use __attribute__, or macros based on it, more freely.
> Yes, I think putting this into gansidecl.h would be fine.
>
> > > #define ATTRIBUTE_UNUSED __attribute__ ((unused))
> > >
> Why bother with the ATTRIBUTE_UNUSED macro? It isn't significantly
> simpler or easier to read than __attribute__ ((unused)).
> jeff
It provides for centralized maintenance. I don't know if any
attributes were added after gcc-2.7, but the current ubiquitous test
assumes that all attributes work as of version 2.7. That may not hold
in the future and we should have a centralized way of handling these on
a per attribute basis. This ensures if we have to distinguish between
them for the purposes of figuring out which ones work as of some gcc
version, they are already separated in the source code and we don't have
to change more than one file.
Below is the patch I came up with. Is it okay to install?
Thanks,
--Kaveh
Fri Apr 3 09:50:55 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gansidecl.h: Check if compiler supports __attribute__. Provide
definitions for ATTRIBUTE_UNUSED and ATTRIBUTE_PRINTF using
__attribute__ when its available. Also provide definitions for
ATTRIBUTE_PRINTF_1, ATTRIBUTE_PRINTF_2 and ATTRIBUTE_PRINTF_3 in
terms of ATTRIBUTE_PRINTF.
* genoutput.c (process_template): Use ATTRIBUTE_UNUSED in place
of __attribute__.
--- egcs-980328/gcc/gansidecl.h~ Sat Feb 7 19:48:07 1998
+++ egcs-980328/gcc/gansidecl.h Fri Apr 3 11:51:52 1998
@@ -46,6 +46,21 @@
#endif
#endif
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __attribute__(x)
+#endif
+
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED __attribute__ ((unused))
+#endif /* ATTRIBUTE_UNUSED */
+
+#ifndef ATTRIBUTE_PRINTF
+#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((format (__printf__, m, n)))
+#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
+#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
+#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
+#endif /* ATTRIBUTE_PRINTF */
+
/* Define a generic NULL if one hasn't already been defined. */
#ifndef NULL
--- /cesl/u26/ghazi/gcc-testing/cvs-egcs/egcs/gcc/genoutput.c Thu Apr 2 10:03:30 1998
+++ egcs-980328/gcc/genoutput.c Fri Apr 3 11:49:02 1998
@@ -562,13 +563,8 @@ process_template (d, template)
printf ("\nstatic char *\n");
printf ("output_%d (operands, insn)\n", d->code_number);
- printf ("#ifdef __GNUC__\n");
- printf (" rtx *operands __attribute__ ((unused));\n");
- printf (" rtx insn __attribute__ ((unused));\n");
- printf ("#else\n");
- printf (" rtx *operands;\n");
- printf (" rtx insn;\n");
- printf ("#endif\n");
+ printf (" rtx *operands ATTRIBUTE_UNUSED;\n");
+ printf (" rtx insn ATTRIBUTE_UNUSED;\n");
printf ("{\n");
/* If the assembler code template starts with a @ it is a newline-separated
--
Kaveh R. Ghazi Project Manager / Custom Development
ghazi@caip.rutgers.edu Icon CMT Corp.
More information about the Gcc
mailing list