From 413519aef85273d74fab2b26aff5ee339c29dc8f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 4 Apr 2011 11:17:11 +0100 Subject: [PATCH] options.texi (ToLower): Document. * doc/options.texi (ToLower): Document. * opt-functions.awk (switch_bit_fields): Initialize cl_tolower field. * opts-common.c (decode_cmdline_option): Handle cl_tolower. * opts.h (cl_option): Add cl_tolower field. * config/rx/rx.c (rx_handle_option): Use strcmp of -mcpu= arguments with lowercase strings. * config/rx/rx.opt (mcpu=): Add ToLower. * config/rx/t-rx (MULTILIB_MATCHES): Don't handle uppercase -mcpu= argument. From-SVN: r171932 --- gcc/ChangeLog | 13 +++++++++++++ gcc/config/rx/rx.c | 6 +++--- gcc/config/rx/rx.opt | 4 ++-- gcc/config/rx/t-rx | 4 ++-- gcc/doc/options.texi | 5 +++++ gcc/opt-functions.awk | 1 + gcc/opts-common.c | 13 +++++++++++++ gcc/opts.h | 2 ++ 8 files changed, 41 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 75f791a7152..4447037cbc6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2011-04-04 Joseph Myers + + * doc/options.texi (ToLower): Document. + * opt-functions.awk (switch_bit_fields): Initialize cl_tolower + field. + * opts-common.c (decode_cmdline_option): Handle cl_tolower. + * opts.h (cl_option): Add cl_tolower field. + * config/rx/rx.c (rx_handle_option): Use strcmp of -mcpu= + arguments with lowercase strings. + * config/rx/rx.opt (mcpu=): Add ToLower. + * config/rx/t-rx (MULTILIB_MATCHES): Don't handle uppercase -mcpu= + argument. + 2011-04-04 Richard Sandiford * config/pdp11/pdp11.h (IRA_COVER_CLASSES): Delete. diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c index 0ed4ee634d2..f0a97abd500 100644 --- a/gcc/config/rx/rx.c +++ b/gcc/config/rx/rx.c @@ -2308,14 +2308,14 @@ rx_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, return value >= 0 && value <= 4; case OPT_mcpu_: - if (strcasecmp (arg, "RX610") == 0) + if (strcmp (arg, "rx610") == 0) rx_cpu_type = RX610; - else if (strcasecmp (arg, "RX200") == 0) + else if (strcmp (arg, "rx200") == 0) { target_flags |= MASK_NO_USE_FPU; rx_cpu_type = RX200; } - else if (strcasecmp (arg, "RX600") != 0) + else if (strcmp (arg, "rx600") != 0) warning (0, "unrecognized argument '%s' to -mcpu= option", arg); break; diff --git a/gcc/config/rx/rx.opt b/gcc/config/rx/rx.opt index 35143dd0f55..99f262c0773 100644 --- a/gcc/config/rx/rx.opt +++ b/gcc/config/rx/rx.opt @@ -1,5 +1,5 @@ ; Command line options for the Renesas RX port of GCC. -; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +; Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. ; Contributed by Red Hat. ; ; This file is part of GCC. @@ -43,7 +43,7 @@ Enable the use of RX FPU instructions. This is the default. ;--------------------------------------------------- mcpu= -Target RejectNegative Joined Var(rx_cpu_name) Report +Target RejectNegative Joined Var(rx_cpu_name) Report ToLower Specify the target RX cpu type. ;--------------------------------------------------- diff --git a/gcc/config/rx/t-rx b/gcc/config/rx/t-rx index 7990bcfaa47..38893143981 100644 --- a/gcc/config/rx/t-rx +++ b/gcc/config/rx/t-rx @@ -1,5 +1,5 @@ # Makefile fragment for building GCC for the Renesas RX target. -# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # Contributed by Red Hat. # # This file is part of GCC. @@ -23,7 +23,7 @@ MULTILIB_OPTIONS = m64bit-doubles nofpu mbig-endian-data MULTILIB_DIRNAMES = 64-bit-double no-fpu-libs big-endian-data -MULTILIB_MATCHES = nofpu=mnofpu nofpu=mcpu?rx200 nofpu=mcpu?RX200 +MULTILIB_MATCHES = nofpu=mnofpu nofpu=mcpu?rx200 MULTILIB_EXCEPTIONS = MULTILIB_EXTRA_OPTS = diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index 608afa2b1b9..69e73645893 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -257,6 +257,11 @@ option handler. @code{UInteger} should also be used on options like @code{-falign-loops}=@var{n} are supported to make sure the saved options are given a full integer. +@item ToLower +The option's argument should be converted to lowercase as part of +putting it in canonical form, and before comparing with the strings +indicated by any @code{Enum} property. + @item NoDriverArg For an option marked @code{Separate}, the option only takes an argument in the compiler proper, not in the driver. This is for diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 19bdf3afb06..68575790e52 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -126,6 +126,7 @@ function switch_bit_fields (flags) flag_init("RejectNegative", flags) \ flag_init("JoinedOrMissing", flags) \ flag_init("UInteger", flags) \ + flag_init("ToLower", flags) \ flag_init("Report", flags) sub(", $", "", result) diff --git a/gcc/opts-common.c b/gcc/opts-common.c index f54d64aff28..e314cb35213 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -567,6 +567,19 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, if (!option_ok_for_language (option, lang_mask)) errors |= CL_ERR_WRONG_LANG; + /* Convert the argument to lowercase if appropriate. */ + if (arg && option->cl_tolower) + { + size_t j; + size_t len = strlen (arg); + char *arg_lower = XNEWVEC (char, len + 1); + + for (j = 0; j < len; j++) + arg_lower[j] = TOLOWER ((unsigned char) arg[j]); + arg_lower[len] = 0; + arg = arg_lower; + } + /* If the switch takes an integer, convert it. */ if (arg && option->cl_uinteger) { diff --git a/gcc/opts.h b/gcc/opts.h index 15e717da0d9..c0c597f8601 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -96,6 +96,8 @@ struct cl_option BOOL_BITFIELD cl_missing_ok : 1; /* Argument is an integer >=0. */ BOOL_BITFIELD cl_uinteger : 1; + /* Argument should be converted to lowercase. */ + BOOL_BITFIELD cl_tolower : 1; /* Report argument with -fverbose-asm */ BOOL_BITFIELD cl_report : 1; /* Offset of field for this option in struct gcc_options, or