This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: handle -Wmain on SPU


If -mstdmain is passed to specify a C99-style main interface, -Wmain
should warn as usual.  This patch implements that (testcase included).

Tested on spu-unknown-elf with no regressions.

Okay for mainline?

2006-12-13  Sa Liu  <saliu@de.ibm.com>
            Ben Elliston  <bje@au.ibm.com>

        * config/spu/spu.h (C_COMMON_OVERRIDE_OPTIONS): Define.
        (REGISTER_TARGET_PRAGMAS): Don't zero warn_main flag.
        * config/spu/spu-protos.h (spu_c_common_override_options):
        Declare.
        * config/spu/spu-c.c (spu_c_common_override_options): New.
        * config/spu/spu.c (spu_override_options): Whitespace fix.

testsuite/ChangeLog
2006-12-13  Ben Elliston  <bje@au.ibm.com>

        * gcc.target/spu/Wmain.c: New test.

Index: gcc/testsuite/gcc.target/spu/Wmain.c
===================================================================
--- gcc/testsuite/gcc.target/spu/Wmain.c	(revision 0)
+++ gcc/testsuite/gcc.target/spu/Wmain.c	(revision 0)
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-Wmain -mstdmain" } */
+
+int main (void *wrong)
+{
+  /* { dg-warning "first argument of 'main' should be 'int'" "" { target spu-*-* } 5 } */
+  /* { dg-warning "'main' takes only zero or two arguments" "" { target spu-*-* } 5 } */
+}
Index: gcc/config/spu/spu-protos.h
===================================================================
--- gcc/config/spu/spu-protos.h	(revision 119816)
+++ gcc/config/spu/spu-protos.h	(working copy)
@@ -24,6 +24,7 @@ extern enum machine_mode spu_eh_return_f
 extern void spu_cpu_cpp_builtins (struct cpp_reader * pfile);
 extern void builtin_define_std (const char *);
 extern void spu_override_options (void);
+extern void spu_c_common_override_options (void);
 extern int valid_subreg (rtx op);
 extern void spu_expand_extv (rtx * ops, int unsignedp);
 extern void spu_expand_insv (rtx * ops);
Index: gcc/config/spu/spu.c
===================================================================
--- gcc/config/spu/spu.c	(revision 119816)
+++ gcc/config/spu/spu.c	(working copy)
@@ -257,7 +257,6 @@ struct gcc_target targetm = TARGET_INITI
 void
 spu_override_options (void)
 {
-
   /* Override some of the default param values.  With so many registers
      larger values are better for these params.  */
   if (MAX_UNROLLED_INSNS == 100)
Index: gcc/config/spu/spu.h
===================================================================
--- gcc/config/spu/spu.h	(revision 119816)
+++ gcc/config/spu/spu.h	(working copy)
@@ -22,6 +22,7 @@
 #define TARGET_VERSION fprintf (stderr, " (spu %s)", __DATE__);
 
 #define OVERRIDE_OPTIONS spu_override_options()
+#define C_COMMON_OVERRIDE_OPTIONS spu_c_common_override_options()
 
 extern int target_flags;
 extern const char *spu_fixed_range_string;
@@ -242,8 +243,6 @@ enum reg_class { 
 
 #define REGISTER_TARGET_PRAGMAS() do {					\
 targetm.resolve_overloaded_builtin = spu_resolve_overloaded_builtin;	\
-  /* Don't give warnings about the main() function. */			\
-warn_main = 0;								\
 }while (0);
 
 
Index: gcc/config/spu/spu-c.c
===================================================================
--- gcc/config/spu/spu-c.c	(revision 119816)
+++ gcc/config/spu/spu-c.c	(working copy)
@@ -141,3 +141,12 @@ spu_cpu_cpp_builtins (struct cpp_reader 
   builtin_define_std ("__vector=__attribute__((__spu_vector__))");
 }
 
+void
+spu_c_common_override_options (void)
+{ 
+  if (!TARGET_STD_MAIN)
+    {
+      /* Don't give warnings about the main() function.  */
+      warn_main = 0;
+    }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]