re PR c/53063 (encode group options in the .opt files)

2012-10-16  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/53063
	PR c/40989
gcc/
	* optc-gen.awk: Handle new form of LangEnabledBy.
	* opts.c (set_Wstrict_aliasing): Declare here. Make static.
	* common.opt (Wstrict-aliasing=,Wstrict-overflow=): Do not use Init.
	* doc/options.texi (LangEnabledBy): Document new form.
	* flags.h (set_Wstrict_aliasing): Do not declare.
c-family/
	* c.opt (Wstrict-aliasing=,Wstrict-overflow=): Use LangEnabledBy.
	* c-opts.c (c_common_handle_option): Do not set them here. Add
	comment.
	(c_common_post_options): Likewise.
testsuite/
	* gcc.dg/Wstrict-overflow-24.c: New.

From-SVN: r192502
parent 80de67b8
2012-10-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53063
PR c/40989
* optc-gen.awk: Handle new form of LangEnabledBy.
* opts.c (set_Wstrict_aliasing): Declare here. Make static.
* common.opt (Wstrict-aliasing=,Wstrict-overflow=): Do not use Init.
* doc/options.texi (LangEnabledBy): Document new form.
* flags.h (set_Wstrict_aliasing): Do not declare.
2012-10-16 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> 2012-10-16 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* reload.c (find_reloads_subreg_address): Remove FORCE_REPLACE * reload.c (find_reloads_subreg_address): Remove FORCE_REPLACE
2012-10-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53063
PR c/40989
* c.opt (Wstrict-aliasing=,Wstrict-overflow=): Use LangEnabledBy.
* c-opts.c (c_common_handle_option): Do not set them here. Add
comment.
(c_common_post_options): Likewise.
2012-10-16 Eric Botcazou <ebotcazou@adacore.com> 2012-10-16 Eric Botcazou <ebotcazou@adacore.com>
* c-ada-spec.c (ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX): Define. * c-ada-spec.c (ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX): Define.
......
...@@ -360,6 +360,7 @@ c_common_handle_option (size_t scode, const char *arg, int value, ...@@ -360,6 +360,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
break; break;
case OPT_Wall: case OPT_Wall:
/* ??? Don't add new options here. Use LangEnabledBy in c.opt. */
handle_generated_option (&global_options, &global_options_set, handle_generated_option (&global_options, &global_options_set,
OPT_Wunused, NULL, value, OPT_Wunused, NULL, value,
c_family_lang_mask, kind, loc, c_family_lang_mask, kind, loc,
...@@ -375,11 +376,7 @@ c_common_handle_option (size_t scode, const char *arg, int value, ...@@ -375,11 +376,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
warn_sequence_point = value; /* Was C only. */ warn_sequence_point = value; /* Was C only. */
warn_switch = value; warn_switch = value;
warn_sizeof_pointer_memaccess = value; warn_sizeof_pointer_memaccess = value;
if (warn_strict_aliasing == -1)
set_Wstrict_aliasing (&global_options, value);
warn_address = value; warn_address = value;
if (warn_strict_overflow == -1)
warn_strict_overflow = value;
warn_array_bounds = value; warn_array_bounds = value;
warn_volatile_register_var = value; warn_volatile_register_var = value;
...@@ -939,11 +936,6 @@ c_common_post_options (const char **pfilename) ...@@ -939,11 +936,6 @@ c_common_post_options (const char **pfilename)
if (warn_pointer_sign == -1) if (warn_pointer_sign == -1)
warn_pointer_sign = 0; warn_pointer_sign = 0;
if (warn_strict_aliasing == -1)
warn_strict_aliasing = 0;
if (warn_strict_overflow == -1)
warn_strict_overflow = 0;
/* -Woverlength-strings is off by default, but is enabled by -Wpedantic. /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
It is never enabled in C++, as the minimum limit is not normative It is never enabled in C++, as the minimum limit is not normative
in that standard. */ in that standard. */
......
...@@ -629,6 +629,14 @@ Wstrict-prototypes ...@@ -629,6 +629,14 @@ Wstrict-prototypes
C ObjC Var(warn_strict_prototypes) Warning C ObjC Var(warn_strict_prototypes) Warning
Warn about unprototyped function declarations Warn about unprototyped function declarations
Wstrict-aliasing=
C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 3, 0)
;
Wstrict-overflow=
C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0)
;
Wstrict-selector-match Wstrict-selector-match
ObjC ObjC++ Var(warn_strict_selector_match) Warning ObjC ObjC++ Var(warn_strict_selector_match) Warning
Warn if type signatures of candidate methods do not match exactly Warn if type signatures of candidate methods do not match exactly
......
...@@ -609,7 +609,7 @@ Common Warning ...@@ -609,7 +609,7 @@ Common Warning
Warn about code which might break strict aliasing rules Warn about code which might break strict aliasing rules
Wstrict-aliasing= Wstrict-aliasing=
Common Joined RejectNegative UInteger Var(warn_strict_aliasing) Init(-1) Warning Common Joined RejectNegative UInteger Var(warn_strict_aliasing) Warning
Warn about code which might break strict aliasing rules Warn about code which might break strict aliasing rules
Wstrict-overflow Wstrict-overflow
...@@ -617,7 +617,7 @@ Common Warning ...@@ -617,7 +617,7 @@ Common Warning
Warn about optimizations that assume that signed overflow is undefined Warn about optimizations that assume that signed overflow is undefined
Wstrict-overflow= Wstrict-overflow=
Common Joined RejectNegative UInteger Var(warn_strict_overflow) Init(-1) Warning Common Joined RejectNegative UInteger Var(warn_strict_overflow) Warning
Warn about optimizations that assume that signed overflow is undefined Warn about optimizations that assume that signed overflow is undefined
Wsuggest-attribute=const Wsuggest-attribute=const
......
...@@ -463,11 +463,15 @@ value of @option{-fmath-errno} for languages that do not use ...@@ -463,11 +463,15 @@ value of @option{-fmath-errno} for languages that do not use
If not explicitly set, the option is set to the value of @option{-@var{opt}}. If not explicitly set, the option is set to the value of @option{-@var{opt}}.
@item LangEnabledBy(@var{language}, @var{opt}) @item LangEnabledBy(@var{language}, @var{opt})
@itemx LangEnabledBy(@var{language}, @var{opt}, @var{posarg}, @var{negarg})
When compiling for the given language, the option is set to the value When compiling for the given language, the option is set to the value
of @option{-@var{opt}}, if not explicitly set. It is possible to of @option{-@var{opt}}, if not explicitly set. In the second form, if
specify several different languages. Each @var{language} must have @var{opt} is used in the positive form then @var{posarg} is considered
been declared by an earlier @code{Language} record. @xref{Option file to be passed to the option, and if @var{opt} is used in the negative
format}. form then @var{negarg} is considered to be passed to the option. It
is possible to specify several different languages. Each
@var{language} must have been declared by an earlier @code{Language}
record. @xref{Option file format}.
@item NoDWARFRecord @item NoDWARFRecord
The option is omitted from the producer string written by The option is omitted from the producer string written by
......
...@@ -37,14 +37,6 @@ extern int base_of_path (const char *path, const char **base_out); ...@@ -37,14 +37,6 @@ extern int base_of_path (const char *path, const char **base_out);
extern bool fast_math_flags_set_p (const struct gcc_options *); extern bool fast_math_flags_set_p (const struct gcc_options *);
extern bool fast_math_flags_struct_set_p (struct cl_optimization *); extern bool fast_math_flags_struct_set_p (struct cl_optimization *);
/* Used to set the level of -Wstrict-aliasing in OPTS, when no level
is specified. The external way to set the default level is to use
-Wstrict-aliasing=level.
ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified,
and 0 otherwise. After calling this function, wstrict_aliasing will be
set to the default value of -Wstrict_aliasing=level. */
extern void set_Wstrict_aliasing (struct gcc_options *opts, int onoff);
/* Now the symbols that are set with `-f' switches. */ /* Now the symbols that are set with `-f' switches. */
......
...@@ -48,7 +48,7 @@ for (i = 0; i < n_opts; i++) { ...@@ -48,7 +48,7 @@ for (i = 0; i < n_opts; i++) {
enabledby[n_enabledby] = enabledby_name; enabledby[n_enabledby] = enabledby_name;
n_enabledby++; n_enabledby++;
} }
enables[enabledby_name] = enables[enabledby_name] opts[i] ","; enables[enabledby_name] = enables[enabledby_name] opts[i] ";";
} }
} }
...@@ -56,10 +56,20 @@ for (i = 0; i < n_opts; i++) { ...@@ -56,10 +56,20 @@ for (i = 0; i < n_opts; i++) {
if (enabledby_arg != "") { if (enabledby_arg != "") {
n_enabledby_arg_langs = split(nth_arg(0, enabledby_arg), enabledby_arg_langs, " "); n_enabledby_arg_langs = split(nth_arg(0, enabledby_arg), enabledby_arg_langs, " ");
enabledby_name = nth_arg(1, enabledby_arg); enabledby_name = nth_arg(1, enabledby_arg);
enabledby_posarg = nth_arg(2, enabledby_arg)
enabledby_negarg = nth_arg(3, enabledby_arg)
enabledby_index = opt_numbers[enabledby_name]; enabledby_index = opt_numbers[enabledby_name];
if (enabledby_index == "") { if (enabledby_index == "") {
print "#error Enabledby: " enabledby_name print "#error LangEnabledby: " enabledby_name
} else { } else {
if (enabledby_posarg != "" && enabledby_negarg != "") {
with_args = "," enabledby_posarg "," enabledby_negarg
} else if (enabledby_posarg == "" && enabledby_negarg == "") {
with_args = ""
} else {
print "#error LangEnabledBy with three arguments, it should have either 2 or 4"
}
for (j = 1; j <= n_enabledby_arg_langs; j++) { for (j = 1; j <= n_enabledby_arg_langs; j++) {
lang_name = lang_sanitized_name(enabledby_arg_langs[j]); lang_name = lang_sanitized_name(enabledby_arg_langs[j]);
lang_index = lang_numbers[enabledby_arg_langs[j]]; lang_index = lang_numbers[enabledby_arg_langs[j]];
...@@ -67,7 +77,7 @@ for (i = 0; i < n_opts; i++) { ...@@ -67,7 +77,7 @@ for (i = 0; i < n_opts; i++) {
enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_name; enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_name;
n_enabledby_lang[lang_index]++; n_enabledby_lang[lang_index]++;
} }
enables[lang_name,enabledby_name] = enables[lang_name,enabledby_name] opts[i] ","; enables[lang_name,enabledby_name] = enables[lang_name,enabledby_name] opts[i] with_args ";";
} }
} }
} }
...@@ -388,7 +398,7 @@ print " { " ...@@ -388,7 +398,7 @@ print " { "
for (i = 0; i < n_enabledby; i++) { for (i = 0; i < n_enabledby; i++) {
enabledby_name = enabledby[i]; enabledby_name = enabledby[i];
print " case " opt_enum(enabledby_name) ":" print " case " opt_enum(enabledby_name) ":"
n_enables = split(enables[enabledby_name], thisenable, ","); n_enables = split(enables[enabledby_name], thisenable, ";");
for (j = 1; j < n_enables; j++) { for (j = 1; j < n_enables; j++) {
opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]); opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]);
if (opt_var_name != "") { if (opt_var_name != "") {
...@@ -431,16 +441,26 @@ for (i = 0; i < n_langs; i++) { ...@@ -431,16 +441,26 @@ for (i = 0; i < n_langs; i++) {
for (k = 0; k < n_enabledby_lang[i]; k++) { for (k = 0; k < n_enabledby_lang[i]; k++) {
enabledby_name = enabledby[lang_name,k]; enabledby_name = enabledby[lang_name,k];
print " case " opt_enum(enabledby_name) ":" print " case " opt_enum(enabledby_name) ":"
n_enables = split(enables[lang_name,enabledby_name], thisenable, ","); n_thisenable = split(enables[lang_name,enabledby_name], thisenable, ";");
for (j = 1; j < n_enables; j++) { for (j = 1; j < n_thisenable; j++) {
opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]); n_thisenable_args = split(thisenable[j], thisenable_args, ",");
if (n_thisenable_args == 1) {
thisenable_opt = thisenable[j];
value = "value";
} else {
thisenable_opt = thisenable_args[1];
with_posarg = thisenable_args[2];
with_negarg = thisenable_args[3];
value = "value ? " with_posarg " : " with_negarg;
}
opt_var_name = var_name(flags[opt_numbers[thisenable_opt]]);
if (opt_var_name != "") { if (opt_var_name != "") {
print " if (!opts_set->x_" opt_var_name ")" print " if (!opts_set->x_" opt_var_name ")"
print " handle_generated_option (opts, opts_set," print " handle_generated_option (opts, opts_set,"
print " " opt_enum(thisenable[j]) ", arg, value," print " " opt_enum(thisenable_opt) ", NULL, " value ","
print " lang_mask, kind, loc, handlers, dc);" print " lang_mask, kind, loc, handlers, dc);"
} else { } else {
print "#error " thisenable[j] " does not have a Var() flag" print "#error " thisenable_opt " does not have a Var() flag"
} }
} }
print " break;\n" print " break;\n"
......
...@@ -37,6 +37,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -37,6 +37,8 @@ along with GCC; see the file COPYING3. If not see
#include "insn-attr-common.h" #include "insn-attr-common.h"
#include "common/common-target.h" #include "common/common-target.h"
static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff);
/* Indexed by enum debug_info_type. */ /* Indexed by enum debug_info_type. */
const char *const debug_type_names[] = const char *const debug_type_names[] =
{ {
...@@ -1801,7 +1803,7 @@ handle_param (struct gcc_options *opts, struct gcc_options *opts_set, ...@@ -1801,7 +1803,7 @@ handle_param (struct gcc_options *opts, struct gcc_options *opts_set,
ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified, ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified,
and 0 otherwise. After calling this function, wstrict_aliasing will be and 0 otherwise. After calling this function, wstrict_aliasing will be
set to the default value of -Wstrict_aliasing=level, currently 3. */ set to the default value of -Wstrict_aliasing=level, currently 3. */
void static void
set_Wstrict_aliasing (struct gcc_options *opts, int onoff) set_Wstrict_aliasing (struct gcc_options *opts, int onoff)
{ {
gcc_assert (onoff == 0 || onoff == 1); gcc_assert (onoff == 0 || onoff == 1);
......
2012-10-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53063
PR c/40989
* gcc.dg/Wstrict-overflow-24.c: New.
2012-10-16 Tobias Burnus <burnus@net-b.de> 2012-10-16 Tobias Burnus <burnus@net-b.de>
PR fortran/50981 PR fortran/50981
......
/* { dg-do compile } */
/* { dg-options "-fstrict-overflow -O2" } */
/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */
#pragma GCC diagnostic error "-Wstrict-overflow"
int
foo (int i)
{
return __builtin_abs (i) >= 0; /* { dg-error "assuming signed overflow does not occur" "correct warning" } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment