This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Error if C++ `init_priority' Attribute Not Supported
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Error if C++ `init_priority' Attribute Not Supported
- From: Jeffrey Oldham <oldham at codesourcery dot com>
- Date: Sun, 14 Jan 2001 19:38:44 -0800
- Cc: Jeffrey Oldham <oldham at codesourcery dot com>
- Organization: CodeSourcery LLC
If an architecture's linker does not support the gcc C++ attribute
init_priority but it is used, issue an error that it is not supported.
The macro "SUPPORTS_INIT_PRIORITY", which may be set in a
configuration file, should be undefined if the attribute is not
supported.
gcc/ChangeLog:
2001-01-14 Jeffrey Oldham <oldham@codesourcery.com>
* defaults.h (SUPPORTS_INIT_PRIORITY): New macro to indicate the
linker supports the init_priority C++ attribute.
* tm.texi (SUPPORTS_INIT_PRIORITY): Documentation for new macro.
* config/mips/iris6.h (SUPPORTS_INIT_PRIORITY): Indicate Irix
linker does not support init_priority C++ attribute.
gcc/cp/ChangeLog:
2001-01-14 Jeffrey Oldham <oldham@codesourcery.com>
* tree.c: Add defaults.h.
(cp_valid_lang_attribute): Incorporate SUPPORTS_INIT_PRIORITY.
* Make-lang.in (cp/tree.o): Add defaults.h.
Tested on mips-sgi-irix6.5 and i686-pc-linux-gnu
Approved by Mark Mitchell (mark@codesourcery.com)
Thanks,
Jeffrey D. Oldham
oldham@codesourcery.com
Index: defaults.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/defaults.h,v
retrieving revision 1.27
diff -c -p -r1.27 defaults.h
*** defaults.h 2000/12/30 15:31:49 1.27
--- defaults.h 2001/01/15 03:27:46
***************
*** 1,7 ****
/* Definitions of various defaults for how to do assembler output
(most of which are designed to be appropriate for GAS or for
some BSD assembler).
! Copyright (C) 1992, 1996, 1997, 1998, 1999, 2000
Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@monkeys.com)
--- 1,7 ----
/* Definitions of various defaults for how to do assembler output
(most of which are designed to be appropriate for GAS or for
some BSD assembler).
! Copyright (C) 1992, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@monkeys.com)
*************** do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNA
*** 166,171 ****
--- 166,177 ----
# define TARGET_ATTRIBUTE_WEAK
# endif
#endif
+
+ /* If the target supports init_priority C++ attribute, give
+ SUPPORTS_INIT_PRIORITY a nonzero value. */
+ #ifndef SUPPORTS_INIT_PRIORITY
+ #define SUPPORTS_INIT_PRIORITY 1
+ #endif /* SUPPORTS_INIT_PRIORITY */
/* If we have a definition of INCOMING_RETURN_ADDR_RTX, assume that
the rest of the DWARF 2 frame unwind support is also provided. */
Index: tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.165
diff -c -p -r1.165 tm.texi
*** tm.texi 2001/01/13 08:57:28 1.165
--- tm.texi 2001/01/15 03:27:54
*************** If defined, @code{main} will call @code{
*** 6387,6392 ****
--- 6387,6399 ----
where the init section is not actually run automatically, but is still
useful for collecting the lists of constructors and destructors.
+ @item SUPPORTS_INIT_PRIORITY
+ @findex SUPPORTS_INIT_PRIORITY
+ If nonzero, the C++ @code{init_priority} attribute is supported and the
+ compiler should emit instructions to control the order of initialization
+ of objects. If zero, the compiler will issue an error message upon
+ encountering an @code{init_priority} attribute.
+
@item ASM_OUTPUT_CONSTRUCTOR (@var{stream}, @var{name})
@findex ASM_OUTPUT_CONSTRUCTOR
Define this macro as a C statement to output on the stream @var{stream}
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/Make-lang.in,v
retrieving revision 1.71
diff -c -p -r1.71 Make-lang.in
*** Make-lang.in 2001/01/13 00:24:39 1.71
--- Make-lang.in 2001/01/15 03:27:54
*************** cp/method.o: cp/method.c $(CXX_TREE_H) t
*** 274,280 ****
cp/cvt.o: cp/cvt.c $(CXX_TREE_H) cp/decl.h flags.h toplev.h convert.h
cp/search.o: cp/search.c $(CXX_TREE_H) stack.h flags.h toplev.h $(RTL_H)
cp/tree.o: cp/tree.c $(CXX_TREE_H) flags.h toplev.h $(GGC_H) $(RTL_H) \
! insn-config.h integrate.h
cp/ptree.o: cp/ptree.c $(CXX_TREE_H) system.h
cp/rtti.o: cp/rtti.c $(CXX_TREE_H) flags.h toplev.h defaults.h
cp/except.o: cp/except.c $(CXX_TREE_H) flags.h $(RTL_H) except.h toplev.h \
--- 274,280 ----
cp/cvt.o: cp/cvt.c $(CXX_TREE_H) cp/decl.h flags.h toplev.h convert.h
cp/search.o: cp/search.c $(CXX_TREE_H) stack.h flags.h toplev.h $(RTL_H)
cp/tree.o: cp/tree.c $(CXX_TREE_H) flags.h toplev.h $(GGC_H) $(RTL_H) \
! insn-config.h integrate.h defaults.h
cp/ptree.o: cp/ptree.c $(CXX_TREE_H) system.h
cp/rtti.o: cp/rtti.c $(CXX_TREE_H) flags.h toplev.h defaults.h
cp/except.o: cp/except.c $(CXX_TREE_H) flags.h $(RTL_H) except.h toplev.h \
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tree.c,v
retrieving revision 1.227
diff -c -p -r1.227 tree.c
*** tree.c 2001/01/02 19:48:02 1.227
--- tree.c 2001/01/15 03:27:56
***************
*** 1,6 ****
/* Language-dependent node constructors for parse phase of GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
! 1999, 2000 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
--- 1,6 ----
/* Language-dependent node constructors for parse phase of GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
! 1999, 2000, 2001 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
*************** Boston, MA 02111-1307, USA. */
*** 31,36 ****
--- 31,37 ----
#include "ggc.h"
#include "insn-config.h"
#include "integrate.h"
+ #include "defaults.h"
static tree bot_manip PARAMS ((tree *, int *, void *));
static tree bot_replace PARAMS ((tree *, int *, void *));
*************** cp_valid_lang_attribute (attr_name, attr
*** 2312,2319 ****
("requested init_priority is reserved for internal use");
}
! DECL_INIT_PRIORITY (decl) = pri;
! return 1;
}
return 0;
--- 2313,2328 ----
("requested init_priority is reserved for internal use");
}
! if (SUPPORTS_INIT_PRIORITY)
! {
! DECL_INIT_PRIORITY (decl) = pri;
! return 1;
! }
! else
! {
! error ("init_priority attribute is not supported on this platform");
! return 0;
! }
}
return 0;
Index: config/mips/iris6.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/mips/iris6.h,v
retrieving revision 1.25
diff -c -p -r1.25 iris6.h
*** iris6.h 2000/12/13 19:34:35 1.25
--- iris6.h 2001/01/15 03:27:56
***************
*** 1,5 ****
/* Definitions of target machine for GNU compiler. Iris version 6.
! Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
This file is part of GNU CC.
--- 1,5 ----
/* Definitions of target machine for GNU compiler. Iris version 6.
! Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
*************** Boston, MA 02111-1307, USA. */
*** 204,209 ****
--- 204,213 ----
} while (0)
#define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
+
+ /* Irix assembler does not support the init_priority C++ attribute. */
+ #undef SUPPORTS_INIT_PRIORITY
+ #define SUPPORTS_INIT_PRIORITY 0
#define POPSECTION_ASM_OP "\t.popsection"