From c2d8909517439e76a739d654661cbd15f5a344a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez?= Date: Sun, 9 Aug 2015 19:30:17 +0000 Subject: [PATCH] options.texi (EnabledBy): Document that the argument must be a Common option. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit gcc/ChangeLog: 2015-08-09 Manuel López-Ibáñez * doc/options.texi (EnabledBy): Document that the argument must be a Common option. * doc/invoke.texi (Wnull-dereference): Move after Wnonnull. Not enabled by -Wall. * optc-gen.awk: Give nicer error messages. Detect if the argument of EnabledBy is not a Common option. * common.opt (Wnull-dereference): Not enabled by -Wall. * opt-functions.awk (lang_enabled_by): Nicer error messages. gcc/c-family/ChangeLog: 2015-08-09 Manuel López-Ibáñez * c.opt (Wchkp): Use LangEnabledBy instead of EnabledBy. From-SVN: r226751 --- gcc/ChangeLog | 11 +++++++++++ gcc/c-family/ChangeLog | 4 ++++ gcc/c-family/c.opt | 2 +- gcc/common.opt | 2 +- gcc/doc/invoke.texi | 19 +++++++++---------- gcc/doc/options.texi | 4 +++- gcc/opt-functions.awk | 6 +++--- gcc/optc-gen.awk | 28 +++++++++++++++++++++++----- 8 files changed, 55 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 154c0bf..f103d41 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2015-08-09 Manuel López-Ibáñez + + * doc/options.texi (EnabledBy): Document that the argument must be + a Common option. + * doc/invoke.texi (Wnull-dereference): Move after Wnonnull. + Not enabled by -Wall. + * optc-gen.awk: Give nicer error messages. Detect if the argument + of EnabledBy is not a Common option. + * common.opt (Wnull-dereference): Not enabled by -Wall. + * opt-functions.awk (lang_enabled_by): Nicer error messages. + 2015-08-09 H.J. Lu * config/i386/driver-i386.c (host_detect_local_cpu): Treat diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d3a6a38..af1f098 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2015-08-09 Manuel López-Ibáñez + + * c.opt (Wchkp): Use LangEnabledBy instead of EnabledBy. + 2015-08-06 Andrew Sutton Braden Obrzut Jason Merrill diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index e86ee12..050dcb0 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -335,7 +335,7 @@ C ObjC C++ ObjC++ Var(warn_char_subscripts) Warning LangEnabledBy(C ObjC C++ Obj Warn about subscripts whose type is \"char\" Wchkp -C ObjC C++ ObjC++ Var(warn_chkp) Warning EnabledBy(Wall) +C ObjC C++ ObjC++ Var(warn_chkp) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) Warn about memory access errors found by Pointer Bounds Checker Wclobbered diff --git a/gcc/common.opt b/gcc/common.opt index fb9e9da..e80eadf 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -593,7 +593,7 @@ Common RejectNegative Joined UInteger Warning -Wlarger-than= Warn if an object is larger than bytes Wnull-dereference -Common Var(warn_null_dereference) Warning EnabledBy(Wall) +Common Var(warn_null_dereference) Warning Warn if dereferencing a NULL pointer may lead to erroneous or undefined behavior Wunsafe-loop-optimizations diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e27f8cc..c26cd87 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -3722,6 +3722,15 @@ requiring a non-null value by the @code{nonnull} function attribute. @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It can be disabled with the @option{-Wno-nonnull} option. +@item -Wnull-dereference +@opindex Wnull-dereference +@opindex Wno-null-dereference +Warn if the compiler detects paths that trigger erroneous or +undefined behavior due to dereferencing a null pointer. This option +is only active when @option{-fdelete-null-pointer-checks} is active, +which is enabled by optimizations in most targets. The precision of +the warnings depends on the optimization options used. + @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)} @opindex Winit-self @opindex Wno-init-self @@ -4158,16 +4167,6 @@ In order to get a warning about an unused function parameter, you must either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies @option{-Wunused}), or separately specify @option{-Wunused-parameter}. -@item -Wnull-dereference -@opindex Wnull-dereference -@opindex Wno-null-dereference -Warn if the compiler detects paths that trigger erroneous or -undefined behavior due to dereferencing a null pointer. This option -is only active when @option{-fdelete-null-pointer-checks} is active, -which is enabled by optimizations in most targets. The precision of -the warnings depends on the optimization options used. This option is -enabled by @option{-Wall}. - @item -Wuninitialized @opindex Wuninitialized @opindex Wno-uninitialized diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index 37ca474..d4cbd98 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -464,7 +464,9 @@ 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}}; multiple options can be given, separated by @code{||}. The third form using @code{&&} specifies that the option is -only set if both @var{opt} and @var{opt2} are set. +only set if both @var{opt} and @var{opt2} are set. The options @var{opt} +and @var{opt2} must have the @code{Common} property; otherwise, use +@code{LangEnabledBy}. @item LangEnabledBy(@var{language}, @var{opt}) @itemx LangEnabledBy(@var{language}, @var{opt}, @var{posarg}, @var{negarg}) diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 60b5a24..c05a50c 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -324,7 +324,7 @@ function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enab } else if (enabledby_posarg == "" && enabledby_negarg == "") { with_args = "" } else { - print "#error LangEnabledBy("enabledby_langs","enabledby_name", " \ + print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \ enabledby_posarg", " enabledby_negargs \ ") with three arguments, it should have either 2 or 4" } @@ -333,8 +333,8 @@ function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enab for (k = 1; k <= n_enabledby_array; k++) { enabledby_index = opt_numbers[enabledby_array[k]]; if (enabledby_index == "") { - print "#error LangEnabledBy("enabledby_langs","enabledby_name", " \ - enabledby_posarg", " enabledby_negargs") has invalid ENABLEDBY_NAME" + print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \ + enabledby_posarg", " enabledby_negargs"), unknown option '" enabledby_name "'" } else { for (j = 1; j <= n_enabledby_arg_langs; j++) { lang_name = lang_sanitized_name(enabledby_arg_langs[j]); diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index fb22405..ed40f7f 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -30,7 +30,21 @@ # Dump that array of options into a C file. END { -# Record first EnabledBy and LangEnabledBy uses. + +# Combine the flags of identical switches. Switches +# appear many times if they are handled by many front +# ends, for example. +for (i = 0; i < n_opts; i++) { + merged_flags[i] = flags[i] +} +for (i = 0; i < n_opts; i++) { + while(i + 1 != n_opts && opts[i] == opts[i + 1] ) { + merged_flags[i + 1] = merged_flags[i] " " merged_flags[i + 1]; + i++; + } +} + +# Record EnabledBy and LangEnabledBy uses. n_enabledby = 0; for (i = 0; i < n_langs; i++) { n_enabledby_lang[i] = 0; @@ -48,15 +62,19 @@ for (i = 0; i < n_opts; i++) { } n_enabledby_names = split(enabledby_arg, enabledby_names, split_sep); if (logical_and != 0 && n_enabledby_names > 2) { - print "#error EnabledBy (Wfoo && Wbar && Wbaz) not currently supported" + print "#error " opts[i] " EnabledBy(Wfoo && Wbar && Wbaz) currently not supported" } for (j = 1; j <= n_enabledby_names; j++) { enabledby_name = enabledby_names[j]; enabledby_index = opt_numbers[enabledby_name]; if (enabledby_index == "") { - print "#error Enabledby: " enabledby_name - } else { - condition = ""; + print "#error " opts[i] " Enabledby(" enabledby_name "), unknown option '" enabledby_name "'" + } else if (!flag_set_p("Common", merged_flags[enabledby_index])) { + print "#error " opts[i] " Enabledby(" enabledby_name "), '" \ + enabledby_name "' must have flag 'Common'" \ + " to use Enabledby(), otherwise use LangEnabledBy()" + } else { + condition = ""; if (logical_and != 0) { opt_var_name_1 = search_var_name(enabledby_names[1], opt_numbers, opts, flags, n_opts); opt_var_name_2 = search_var_name(enabledby_names[2], opt_numbers, opts, flags, n_opts); -- 2.7.4