[4.7] Avoid global state in alpha_handle_option

Joseph S. Myers joseph@codesourcery.com
Wed Mar 2 01:59:00 GMT 2011


This patch, for 4.7 and relative to a tree with
<http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01709.html> applied,
stops the Alpha handle_option hook from using global state.

Tested building cc1 and xgcc for cross to alpha-linux-gnu.  Will
commit to trunk for 4.7 in the absence of target maintainer
objections.

2011-03-01  Joseph Myers  <joseph@codesourcery.com>

	* config/alpha/alpha.c (alpha_handle_option): Access target_flags
	via opts pointer.  Use error_at.  Don't assert that global
	structures are in use.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/alpha/alpha.c gcc-mainline/gcc/config/alpha/alpha.c
--- gcc-mainline-1/gcc/config/alpha/alpha.c	2011-02-23 09:07:36.000000000 -0800
+++ gcc-mainline/gcc/config/alpha/alpha.c	2011-03-01 15:03:39.000000000 -0800
@@ -218,32 +218,30 @@ static const struct default_options alph
 /* Implement TARGET_HANDLE_OPTION.  */
 
 static bool
-alpha_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
+alpha_handle_option (struct gcc_options *opts,
+		     struct gcc_options *opts_set ATTRIBUTE_UNUSED,
 		     const struct cl_decoded_option *decoded,
-		     location_t loc ATTRIBUTE_UNUSED)
+		     location_t loc)
 {
   size_t code = decoded->opt_index;
   const char *arg = decoded->arg;
   int value = decoded->value;
 
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
-
   switch (code)
     {
     case OPT_mfp_regs:
       if (value == 0)
-	target_flags |= MASK_SOFT_FP;
+	opts->x_target_flags |= MASK_SOFT_FP;
       break;
 
     case OPT_mieee:
     case OPT_mieee_with_inexact:
-      target_flags |= MASK_IEEE_CONFORMANT;
+      opts->x_target_flags |= MASK_IEEE_CONFORMANT;
       break;
 
     case OPT_mtls_size_:
       if (value != 16 && value != 32 && value != 64)
-	error ("bad value %qs for -mtls-size switch", arg);
+	error_at (loc, "bad value %qs for -mtls-size switch", arg);
       break;
     }
 

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list