aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg McGary <greg@mcgary.org>2000-08-24 20:09:27 +0000
committerGreg McGary <gkm@gcc.gnu.org>2000-08-24 20:09:27 +0000
commit5b47282c68f4e38146f46b66d5e6d3d90fe25a4d (patch)
tree71324c35deb4c607104811c9294afcf32e897922
parent87ae0c74eb1e515d6d7c97892fdcaf11db61dea4 (diff)
downloadgcc-5b47282c68f4e38146f46b66d5e6d3d90fe25a4d.zip
gcc-5b47282c68f4e38146f46b66d5e6d3d90fe25a4d.tar.gz
gcc-5b47282c68f4e38146f46b66d5e6d3d90fe25a4d.tar.bz2
tree.h (enum tree_index): New member `TI_MAIN_IDENTIFIER'.
* tree.h (enum tree_index): New member `TI_MAIN_IDENTIFIER'. (MAIN_NAME_P, main_identifier_node): New macros. * c-common.c (c_common_nodes_and_builtins): Init main_identifier_node. * c-decl.c (start_decl, grokdeclarator, start_function, store_parm_decls, finish_function): Use MAIN_NAME_P. * config/avr/avr.c (function_prologue, function_epilogue): Likewise. * config/i386/cygwin.h (SUBTARGET_PROLOGUE): Likewise. * config/i386/win32.h (SUBTARGET_PROLOGUE): Likewise. * config/pdp11/pdp11.c (output_function_prologue): Likewise. From-SVN: r35945
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/c-common.c2
-rw-r--r--gcc/c-decl.c16
-rw-r--r--gcc/config/avr/avr.c6
-rw-r--r--gcc/config/i386/cygwin.h3
-rw-r--r--gcc/config/i386/win32.h3
-rw-r--r--gcc/config/pdp11/pdp11.c3
-rw-r--r--gcc/tree.h5
8 files changed, 32 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2d10fb5..b76a4fb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,17 @@
2000-08-24 Greg McGary <greg@mcgary.org>
+ * tree.h (enum tree_index): New member `TI_MAIN_IDENTIFIER'.
+ (MAIN_NAME_P, main_identifier_node): New macros.
+ * c-common.c (c_common_nodes_and_builtins): Init main_identifier_node.
+ * c-decl.c (start_decl, grokdeclarator, start_function,
+ store_parm_decls, finish_function): Use MAIN_NAME_P.
+ * config/avr/avr.c (function_prologue, function_epilogue): Likewise.
+ * config/i386/cygwin.h (SUBTARGET_PROLOGUE): Likewise.
+ * config/i386/win32.h (SUBTARGET_PROLOGUE): Likewise.
+ * config/pdp11/pdp11.c (output_function_prologue): Likewise.
+
+2000-08-24 Greg McGary <greg@mcgary.org>
+
* cppfiles.c (actual_directory): Don't write beyond `dir'
when it contains "".
* real.c (asctoeg): Stay within bounds of etens[][].
diff --git a/gcc/c-common.c b/gcc/c-common.c
index a7eaec8..9af892a 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -4182,6 +4182,8 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins)
BUILT_IN_NORMAL, NULL_PTR);
#endif
+ main_identifier_node = get_identifier ("main");
+
/* ??? Perhaps there's a better place to do this. But it is related
to __builtin_va_arg, so it isn't that off-the-wall. */
lang_type_promotes_to = simple_type_promotes_to;
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 17b131a..59b238b 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -3430,7 +3430,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
register tree tem;
if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL
- && !strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "main"))
+ && MAIN_NAME_P (DECL_NAME (decl)))
warning_with_decl (decl, "`%s' is usually a function");
if (initialized)
@@ -4827,7 +4827,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
/* Record presence of `inline', if it is reasonable. */
if (inlinep)
{
- if (! strcmp (IDENTIFIER_POINTER (declarator), "main"))
+ if (MAIN_NAME_P (declarator))
warning ("cannot inline function `main'");
else
/* Assume that otherwise the function can be inlined. */
@@ -5892,7 +5892,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes)
else if (warn_missing_prototypes
&& TREE_PUBLIC (decl1)
&& !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0)
- && strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))))
+ && ! MAIN_NAME_P (DECL_NAME (decl1)))
warning_with_decl (decl1, "no previous prototype for `%s'");
/* Optionally warn of any def with no previous prototype
if the function has already been used. */
@@ -5905,7 +5905,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes)
else if (warn_missing_declarations
&& TREE_PUBLIC (decl1)
&& old_decl == 0
- && strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))))
+ && ! MAIN_NAME_P (DECL_NAME (decl1)))
warning_with_decl (decl1, "no previous declaration for `%s'");
/* Optionally warn of any def with no previous declaration
if the function has already been used. */
@@ -5934,8 +5934,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes)
TREE_PUBLIC (decl1) = 0;
/* Warn for unlikely, improbable, or stupid declarations of `main'. */
- if (warn_main > 0
- && strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))) == 0)
+ if (warn_main > 0 && MAIN_NAME_P (DECL_NAME (decl1)))
{
tree args;
int argct = 0;
@@ -6461,7 +6460,7 @@ store_parm_decls ()
/* If this function is `main', emit a call to `__main'
to run global initializers, etc. */
if (DECL_NAME (fndecl)
- && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") == 0
+ && MAIN_NAME_P (DECL_NAME (fndecl))
&& DECL_CONTEXT (fndecl) == NULL_TREE)
expand_main_function ();
}
@@ -6641,8 +6640,7 @@ finish_function (nested)
setjmp_protect_args ();
}
- if (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main")
- && flag_hosted)
+ if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted)
{
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
!= integer_type_node)
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 14ea8a9..6dec0c5 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -469,7 +469,7 @@ function_prologue (FILE *file, int size)
interrupt_func_p = interrupt_function_p (current_function_decl);
signal_func_p = signal_function_p (current_function_decl);
leaf_func_p = leaf_function_p ();
- main_p = ! strcmp ("main", current_function_name);
+ main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
live_seq = sequent_regs_live ();
minimize = (TARGET_CALL_PROLOGUES
&& !interrupt_func_p && !signal_func_p && live_seq);
@@ -604,7 +604,7 @@ function_epilogue (FILE *file, int size)
interrupt_func_p = interrupt_function_p (current_function_decl);
signal_func_p = signal_function_p (current_function_decl);
leaf_func_p = leaf_function_p ();
- main_p = ! strcmp ("main", current_function_name);
+ main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
function_size = (INSN_ADDRESSES (INSN_UID (get_last_insn ()))
- INSN_ADDRESSES (INSN_UID (get_insns ())));
live_seq = sequent_regs_live ();
@@ -3643,7 +3643,7 @@ order_regs_for_local_alloc (void)
int *order = (TARGET_ORDER_1 ? order_1 :
TARGET_ORDER_2 ? order_2 :
order_0);
- for (i=0; i < sizeof (order_0) / sizeof (order_0[0]); ++i)
+ for (i=0; i < ARRAY_SIZE (order_0); ++i)
reg_alloc_order[i] = order[i];
}
diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h
index 5839068..916753d 100644
--- a/gcc/config/i386/cygwin.h
+++ b/gcc/config/i386/cygwin.h
@@ -489,8 +489,7 @@ do { \
#define SUBTARGET_PROLOGUE \
if (profile_flag \
- && strcmp (IDENTIFIER_POINTER (DECL_NAME (current_function_decl)),\
- "main") == 0) \
+ && MAIN_NAME_P (DECL_NAME (current_function_decl))) \
{ \
emit_call_insn (gen_rtx (CALL, VOIDmode, \
gen_rtx_MEM (FUNCTION_MODE, \
diff --git a/gcc/config/i386/win32.h b/gcc/config/i386/win32.h
index 12ae5a8..bc7619f 100644
--- a/gcc/config/i386/win32.h
+++ b/gcc/config/i386/win32.h
@@ -272,8 +272,7 @@ do { \
#define SUBTARGET_PROLOGUE \
if (profile_flag \
- && strcmp (IDENTIFIER_POINTER (DECL_NAME (current_function_decl)),\
- "main") == 0) \
+ && MAIN_NAME_P (DECL_NAME (current_function_decl)) \
{ \
rtx xops[1]; \
xops[0] = gen_rtx_MEM (FUNCTION_MODE, \
diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c
index 55839036..fc98a8c 100644
--- a/gcc/config/pdp11/pdp11.c
+++ b/gcc/config/pdp11/pdp11.c
@@ -110,8 +110,7 @@ output_function_prologue(stream, size)
/* if we are outputting code for main,
the switch FPU to right mode if TARGET_FPU */
- if ( (strcmp ("main", current_function_name) == 0)
- && TARGET_FPU)
+ if (MAIN_NAME_P (DECL_NAME (current_function_decl)) && TARGET_FPU)
{
fprintf(stream, "\t;/* switch cpu to double float, single integer */\n");
fprintf(stream, "\tsetd\n");
diff --git a/gcc/tree.h b/gcc/tree.h
index 06688a8..0adf014 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1745,6 +1745,8 @@ enum tree_index
TI_V4HI_TYPE,
TI_V2SI_TYPE,
+ TI_MAIN_IDENTIFIER,
+
TI_MAX
};
@@ -1791,6 +1793,9 @@ extern tree global_trees[TI_MAX];
#define ptrdiff_type_node global_trees[TI_PTRDIFF_TYPE]
#define va_list_type_node global_trees[TI_VA_LIST_TYPE]
+#define main_identifier_node global_trees[TI_MAIN_IDENTIFIER]
+#define MAIN_NAME_P(NODE) (IDENTIFIER_NODE_CHECK (NODE) == main_identifier_node)
+
#define V4SF_type_node global_trees[TI_V4SF_TYPE]
#define V4SI_type_node global_trees[TI_V4SI_TYPE]
#define V8QI_type_node global_trees[TI_V8QI_TYPE]