summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-16 15:31:46 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-16 15:31:46 +0000
commit77b27208e4842b5adb8d007d52ca6bbaa03f0e6d (patch)
tree4ce566a273abe5c8b53f22c6bfb4b3a8226b26e0
parentb2a4240a1c8eeb25325a5ba4a8dd68f5406bff6b (diff)
downloadgcc-77b27208e4842b5adb8d007d52ca6bbaa03f0e6d.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192502 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c-family/ChangeLog9
-rw-r--r--gcc/c-family/c-opts.c10
-rw-r--r--gcc/c-family/c.opt8
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/doc/options.texi12
-rw-r--r--gcc/flags.h8
-rw-r--r--gcc/optc-gen.awk38
-rw-r--r--gcc/opts.c4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-overflow-24.c10
11 files changed, 86 insertions, 33 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 56a2f56e771..8d639811a3a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+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>
* reload.c (find_reloads_subreg_address): Remove FORCE_REPLACE
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 8cc5c56a919..e2499fb8dbe 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,12 @@
+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>
* c-ada-spec.c (ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX): Define.
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 29121b5d474..ebbf7d91c67 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -360,6 +360,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
break;
case OPT_Wall:
+ /* ??? Don't add new options here. Use LangEnabledBy in c.opt. */
handle_generated_option (&global_options, &global_options_set,
OPT_Wunused, NULL, value,
c_family_lang_mask, kind, loc,
@@ -375,11 +376,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
warn_sequence_point = value; /* Was C only. */
warn_switch = value;
warn_sizeof_pointer_memaccess = value;
- if (warn_strict_aliasing == -1)
- set_Wstrict_aliasing (&global_options, value);
warn_address = value;
- if (warn_strict_overflow == -1)
- warn_strict_overflow = value;
warn_array_bounds = value;
warn_volatile_register_var = value;
@@ -939,11 +936,6 @@ c_common_post_options (const char **pfilename)
if (warn_pointer_sign == -1)
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.
It is never enabled in C++, as the minimum limit is not normative
in that standard. */
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index b02c515327c..316698468c1 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -629,6 +629,14 @@ Wstrict-prototypes
C ObjC Var(warn_strict_prototypes) Warning
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
ObjC ObjC++ Var(warn_strict_selector_match) Warning
Warn if type signatures of candidate methods do not match exactly
diff --git a/gcc/common.opt b/gcc/common.opt
index 6de670b8ae5..0c6d578335a 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -609,7 +609,7 @@ Common Warning
Warn about code which might break strict aliasing rules
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
Wstrict-overflow
@@ -617,7 +617,7 @@ Common Warning
Warn about optimizations that assume that signed overflow is undefined
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
Wsuggest-attribute=const
diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 9c004c8cd3f..8011502f9f1 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -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}}.
@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
-of @option{-@var{opt}}, if not explicitly set. 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}.
+of @option{-@var{opt}}, if not explicitly set. In the second form, if
+@var{opt} is used in the positive form then @var{posarg} is considered
+to be passed to the option, and if @var{opt} is used in the negative
+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
The option is omitted from the producer string written by
diff --git a/gcc/flags.h b/gcc/flags.h
index 141185befc7..d56d5411e7b 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -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_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. */
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 0abe6bcf2a8..2b168756ef5 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -48,7 +48,7 @@ for (i = 0; i < n_opts; i++) {
enabledby[n_enabledby] = enabledby_name;
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++) {
if (enabledby_arg != "") {
n_enabledby_arg_langs = split(nth_arg(0, enabledby_arg), enabledby_arg_langs, " ");
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];
if (enabledby_index == "") {
- print "#error Enabledby: " enabledby_name
+ print "#error LangEnabledby: " enabledby_name
} 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++) {
lang_name = lang_sanitized_name(enabledby_arg_langs[j]);
lang_index = lang_numbers[enabledby_arg_langs[j]];
@@ -67,7 +77,7 @@ for (i = 0; i < n_opts; i++) {
enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_name;
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 " { "
for (i = 0; i < n_enabledby; i++) {
enabledby_name = enabledby[i];
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++) {
opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]);
if (opt_var_name != "") {
@@ -431,16 +441,26 @@ for (i = 0; i < n_langs; i++) {
for (k = 0; k < n_enabledby_lang[i]; k++) {
enabledby_name = enabledby[lang_name,k];
print " case " opt_enum(enabledby_name) ":"
- n_enables = split(enables[lang_name,enabledby_name], thisenable, ",");
- for (j = 1; j < n_enables; j++) {
- opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]);
+ n_thisenable = split(enables[lang_name,enabledby_name], thisenable, ";");
+ for (j = 1; j < n_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 != "") {
print " if (!opts_set->x_" opt_var_name ")"
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);"
} else {
- print "#error " thisenable[j] " does not have a Var() flag"
+ print "#error " thisenable_opt " does not have a Var() flag"
}
}
print " break;\n"
diff --git a/gcc/opts.c b/gcc/opts.c
index ccfe3c70a91..aea0cfc839f 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -37,6 +37,8 @@ along with GCC; see the file COPYING3. If not see
#include "insn-attr-common.h"
#include "common/common-target.h"
+static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff);
+
/* Indexed by enum debug_info_type. */
const char *const debug_type_names[] =
{
@@ -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,
and 0 otherwise. After calling this function, wstrict_aliasing will be
set to the default value of -Wstrict_aliasing=level, currently 3. */
-void
+static void
set_Wstrict_aliasing (struct gcc_options *opts, int onoff)
{
gcc_assert (onoff == 0 || onoff == 1);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5ebe169568c..6c6bf05ef70 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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>
PR fortran/50981
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-24.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-24.c
new file mode 100644
index 00000000000..05e8dd14484
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-24.c
@@ -0,0 +1,10 @@
+/* { 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" } */
+}