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, ARM] Fox target/69180] #pragma GCC target should not warn about redefined macros


as discussed with Kyrill (https://gcc.gnu.org/ml/gcc-patches/2016-01/msg00307.html), this patch avoids confusing (for the testsuite) macro redefinition warning or pedantic errors when the user changes FP versions implicitly with a #pragma GCC target. The warning is kept when the macro is redefined explicitly by the user.

tested on arm-linux-gnueabi for {,-mfpu=neon-fp-armv8,-mfpu=neon}


2016-01-06  Christian Bruel  <christian.bruel@st.com>

	PR target/69180
	* config/arm/arm-c.c (arm_pragma_target_parse): Set NODE_CONDITIONAL
	for __ARM_NEON_FP, __ARM_FP, _ARM_FEATURE_LDREX.

2016-01-06  Christian Bruel  <christian.bruel@st.com>

	PR target/69180
	* gcc.target/arm/pr69180.c: New test.

Index: config/arm/arm-c.c
===================================================================
--- config/arm/arm-c.c	(revision 232101)
+++ config/arm/arm-c.c	(working copy)
@@ -23,6 +23,7 @@
 #include "c-family/c-common.h"
 #include "tm_p.h"
 #include "c-family/c-pragma.h"
+#include "stringpool.h"
 
 /* Output C specific EABI object attributes.  These can not be done in
    arm.c because they require information from the C frontend.  */
@@ -245,8 +246,18 @@ arm_pragma_target_parse (tree args, tree
 
       /* Update macros.  */
       gcc_assert (cur_opt->x_target_flags == target_flags);
-      /* This one can be redefined by the pragma without warning.  */
-      cpp_undef (parse_in, "__ARM_FP");
+
+      /* Don't warn for macros that have context sensitive values depending on
+	 other attributes.
+	 See warn_of_redefinition, Reset after cpp_create_definition.  */
+      tree acond_macro = get_identifier ("__ARM_NEON_FP");
+      C_CPP_HASHNODE (acond_macro)->flags |= NODE_CONDITIONAL ;
+
+      acond_macro = get_identifier ("__ARM_FP");
+      C_CPP_HASHNODE (acond_macro)->flags |= NODE_CONDITIONAL;
+
+      acond_macro = get_identifier ("__ARM_FEATURE_LDREX");
+      C_CPP_HASHNODE (acond_macro)->flags |= NODE_CONDITIONAL;
 
       arm_cpu_builtins (parse_in);
 
Index: testsuite/gcc.target/arm/pr69180.c
===================================================================
--- testsuite/gcc.target/arm/pr69180.c	(revision 0)
+++ testsuite/gcc.target/arm/pr69180.c	(working copy)
@@ -0,0 +1,16 @@
+/* PR target/69180
+   Check that __ARM_NEON_FP redefinition warns for user setting and not for
+   #pragma GCC target.  */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-mfloat-abi=softfp -mfpu=neon" } */
+
+#pragma GCC target ("fpu=neon-fp-armv8")
+
+#define __ARM_NEON_FP 0       
+#define __ARM_FP 0            
+#define __ARM_FEATURE_LDREX 0 
+
+/* { dg-warning ".__ARM_NEON_FP. redefined" "" { target *-*-* } 10 }  */
+/* { dg-warning ".__ARM_FP. redefined" "" { target *-*-* } 11 } */
+/* { dg-warning ".__ARM_FEATURE_LDREX. redefined" "" { target *-*-* } 12 } */

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