From patchwork Tue Mar 29 22:00:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 88866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6366AB6F44 for ; Wed, 30 Mar 2011 09:01:05 +1100 (EST) Received: (qmail 30463 invoked by alias); 29 Mar 2011 22:01:03 -0000 Received: (qmail 30440 invoked by uid 22791); 29 Mar 2011 22:01:00 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Mar 2011 22:00:51 +0000 Received: (qmail 24115 invoked from network); 29 Mar 2011 22:00:50 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Mar 2011 22:00:50 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.72) (envelope-from ) id 1Q4gy0-0001mP-6P for gcc-patches@gcc.gnu.org; Tue, 29 Mar 2011 22:00:48 +0000 Date: Tue, 29 Mar 2011 22:00:48 +0000 (UTC) From: "Joseph S. Myers" To: gcc-patches@gcc.gnu.org Subject: Make option flags consistently unsigned Message-ID: MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch makes variables, fields, parameters and macros used for command-line option flags consistently unsigned. In most places they were already unsigned, but the CL_* values themselves were signed and some other places used signed int for flags. As noted in this makes bit 31 available for use for another flag (1U << 31 is more appropriate than 1 << 31, which is not defined in ISO C). It is logically right for such a collection of flags to be unsigned, but it will be necessary soon to follow up by splitting this field. (I have two uses of flag bits I expect to add soon: one to say that an option's argument is case-insensitive, one to indicate that an option is an alias for the negative form of another option.) Bootstrapped with no regressions on x86_64-unknown-linux-gnu. Applied to mainline. 2011-03-29 Joseph Myers * lto-opts.c (register_user_option_p, lto_register_user_option): Make type argument unsigned. * lto-streamer.h (lto_register_user_option): Make type argument unsigned. * opth-gen.awk: Make CL_* macros unsigned. * opts-common.c (find_opt): Make lang_mask argument unsigned. * opts.h (CL_PARAMS, CL_WARNING, CL_OPTIMIZATION, CL_DRIVER, CL_TARGET, CL_COMMON, CL_SEPARATE_NARGS_MASK, CL_SEPARATE_ALIAS, CL_NO_DRIVER_ARG, CL_REJECT_DRIVER, CL_SAVE, CL_DISABLED, CL_REPORT, CL_JOINED, CL_SEPARATE, CL_REJECT_NEGATIVE, CL_MISSING_OK, CL_UINTEGER, CL_UNDOCUMENTED): Make unsigned. (find_opt): Make lang_mask argument unsigned. Index: opts-common.c =================================================================== --- opts-common.c (revision 171675) +++ opts-common.c (working copy) @@ -1,5 +1,5 @@ /* Command line option handling. - Copyright (C) 2006, 2007, 2008, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2008, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -52,7 +52,7 @@ static void prune_options (struct cl_dec front end, the longest match for a different front end is returned (or N_OPTS if none) and the caller emits an error message. */ size_t -find_opt (const char *input, int lang_mask) +find_opt (const char *input, unsigned int lang_mask) { size_t mn, mn_orig, mx, md, opt_len; size_t match_wrong_lang; Index: opts.h =================================================================== --- opts.h (revision 171675) +++ opts.h (working copy) @@ -1,5 +1,5 @@ /* Command line option handling. - Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 + Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -83,12 +83,12 @@ extern const unsigned int cl_options_cou extern const char *const lang_names[]; extern const unsigned int cl_lang_count; -#define CL_PARAMS (1 << 11) /* Fake entry. Used to display --param info with --help. */ -#define CL_WARNING (1 << 12) /* Enables an (optional) warning message. */ -#define CL_OPTIMIZATION (1 << 13) /* Enables an (optional) optimization. */ -#define CL_DRIVER (1 << 14) /* Driver option. */ -#define CL_TARGET (1 << 15) /* Target-specific option. */ -#define CL_COMMON (1 << 16) /* Language-independent. */ +#define CL_PARAMS (1U << 11) /* Fake entry. Used to display --param info with --help. */ +#define CL_WARNING (1U << 12) /* Enables an (optional) warning message. */ +#define CL_OPTIMIZATION (1U << 13) /* Enables an (optional) optimization. */ +#define CL_DRIVER (1U << 14) /* Driver option. */ +#define CL_TARGET (1U << 15) /* Target-specific option. */ +#define CL_COMMON (1U << 16) /* Language-independent. */ #define CL_MIN_OPTION_CLASS CL_PARAMS #define CL_MAX_OPTION_CLASS CL_COMMON @@ -101,20 +101,20 @@ extern const unsigned int cl_lang_count; /* Options marked with CL_SEPARATE take a number of separate arguments (1 to 4) that is one more than the number in this bit-field. */ #define CL_SEPARATE_NARGS_SHIFT 17 -#define CL_SEPARATE_NARGS_MASK (3 << CL_SEPARATE_NARGS_SHIFT) +#define CL_SEPARATE_NARGS_MASK (3U << CL_SEPARATE_NARGS_SHIFT) -#define CL_SEPARATE_ALIAS (1 << 19) /* Option is an alias when used with separate argument. */ -#define CL_NO_DRIVER_ARG (1 << 20) /* Option takes no argument in the driver. */ -#define CL_REJECT_DRIVER (1 << 21) /* Reject this option in the driver. */ -#define CL_SAVE (1 << 22) /* Target-specific option for attribute. */ -#define CL_DISABLED (1 << 23) /* Disabled in this configuration. */ -#define CL_REPORT (1 << 24) /* Report argument with -fverbose-asm */ -#define CL_JOINED (1 << 25) /* If takes joined argument. */ -#define CL_SEPARATE (1 << 26) /* If takes a separate argument. */ -#define CL_REJECT_NEGATIVE (1 << 27) /* Reject no- form. */ -#define CL_MISSING_OK (1 << 28) /* Missing argument OK (joined). */ -#define CL_UINTEGER (1 << 29) /* Argument is an integer >=0. */ -#define CL_UNDOCUMENTED (1 << 30) /* Do not output with --help. */ +#define CL_SEPARATE_ALIAS (1U << 19) /* Option is an alias when used with separate argument. */ +#define CL_NO_DRIVER_ARG (1U << 20) /* Option takes no argument in the driver. */ +#define CL_REJECT_DRIVER (1U << 21) /* Reject this option in the driver. */ +#define CL_SAVE (1U << 22) /* Target-specific option for attribute. */ +#define CL_DISABLED (1U << 23) /* Disabled in this configuration. */ +#define CL_REPORT (1U << 24) /* Report argument with -fverbose-asm */ +#define CL_JOINED (1U << 25) /* If takes joined argument. */ +#define CL_SEPARATE (1U << 26) /* If takes a separate argument. */ +#define CL_REJECT_NEGATIVE (1U << 27) /* Reject no- form. */ +#define CL_MISSING_OK (1U << 28) /* Missing argument OK (joined). */ +#define CL_UINTEGER (1U << 29) /* Argument is an integer >=0. */ +#define CL_UNDOCUMENTED (1U << 30) /* Do not output with --help. */ /* Flags for an enumerated option argument. */ #define CL_ENUM_CANONICAL (1 << 0) /* Canonical for this value. */ @@ -280,7 +280,7 @@ extern const char **in_fnames; extern unsigned num_in_fnames; -size_t find_opt (const char *input, int lang_mask); +size_t find_opt (const char *input, unsigned int lang_mask); extern int integral_argument (const char *arg); extern bool enum_value_to_arg (const struct cl_enum_arg *enum_args, const char **argp, int value, Index: opth-gen.awk =================================================================== --- opth-gen.awk (revision 171675) +++ opth-gen.awk (working copy) @@ -451,9 +451,9 @@ for (i = 0; i < n_langs; i++) { macros[i] = "CL_" langs[i] gsub( "[^" alnum "_]", "X", macros[i] ) s = substr(" ", length (macros[i])) - print "#define " macros[i] s " (1 << " i ")" + print "#define " macros[i] s " (1U << " i ")" } -print "#define CL_LANG_ALL ((1 << " n_langs ") - 1)" +print "#define CL_LANG_ALL ((1U << " n_langs ") - 1)" print "" print "enum opt_code" Index: lto-opts.c =================================================================== --- lto-opts.c (revision 171675) +++ lto-opts.c (working copy) @@ -194,7 +194,7 @@ input_string_block (struct lto_input_blo Among others, optimization options may well be appropriate here. */ static bool -register_user_option_p (size_t code, int type) +register_user_option_p (size_t code, unsigned int type) { if (type == CL_TARGET) return true; @@ -215,7 +215,8 @@ register_user_option_p (size_t code, int If relevant to LTO, save it in the user options vector. */ void -lto_register_user_option (size_t code, const char *arg, int value, int type) +lto_register_user_option (size_t code, const char *arg, int value, + unsigned int type) { if (register_user_option_p (code, type)) { Index: lto-streamer.h =================================================================== --- lto-streamer.h (revision 171675) +++ lto-streamer.h (working copy) @@ -1,7 +1,7 @@ /* Data structures and declarations used for reading and writing GIMPLE to a file stream. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Doug Kwan This file is part of GCC. @@ -933,7 +933,7 @@ extern GTY(()) VEC(tree,gc) *lto_global_ /* In lto-opts.c. */ -extern void lto_register_user_option (size_t, const char *, int, int); +extern void lto_register_user_option (size_t, const char *, int, unsigned int); extern void lto_read_file_options (struct lto_file_decl_data *); extern void lto_write_options (void); extern void lto_reissue_options (void);