Patchwork [4.7] Avoid global state in alpha_handle_option

login
register
mail settings
Submitter Joseph S. Myers
Date March 2, 2011, 1:59 a.m.
Message ID <Pine.LNX.4.64.1103020158140.23754@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/85016/
State New
Headers show

Comments

Joseph S. Myers - March 2, 2011, 1:59 a.m.
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.
Richard Henderson - March 2, 2011, 9:59 p.m.
On 03/02/2011 11:59 AM, Joseph S. Myers wrote:
> 	* 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.

Looks good, thanks.


r~

Patch

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;
     }