options.texi (EnabledBy): Document that the argument must be a Common option.

gcc/ChangeLog:

2015-08-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* 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  <manu@gcc.gnu.org>

	* c.opt (Wchkp): Use LangEnabledBy instead of EnabledBy.

From-SVN: r226751
parent 18a2180d
2015-08-09 Manuel López-Ibáñez <manu@gcc.gnu.org>
* 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 <hongjiu.lu@intel.com> 2015-08-09 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/driver-i386.c (host_detect_local_cpu): Treat * config/i386/driver-i386.c (host_detect_local_cpu): Treat
......
2015-08-09 Manuel López-Ibáñez <manu@gcc.gnu.org>
* c.opt (Wchkp): Use LangEnabledBy instead of EnabledBy.
2015-08-06 Andrew Sutton <andrew.n.sutton@gmail.com> 2015-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
Braden Obrzut <admin@maniacsvault.net> Braden Obrzut <admin@maniacsvault.net>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
......
...@@ -335,7 +335,7 @@ C ObjC C++ ObjC++ Var(warn_char_subscripts) Warning LangEnabledBy(C ObjC C++ Obj ...@@ -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\" Warn about subscripts whose type is \"char\"
Wchkp 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 Warn about memory access errors found by Pointer Bounds Checker
Wclobbered Wclobbered
......
...@@ -593,7 +593,7 @@ Common RejectNegative Joined UInteger Warning ...@@ -593,7 +593,7 @@ Common RejectNegative Joined UInteger Warning
-Wlarger-than=<number> Warn if an object is larger than <number> bytes -Wlarger-than=<number> Warn if an object is larger than <number> bytes
Wnull-dereference 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 Warn if dereferencing a NULL pointer may lead to erroneous or undefined behavior
Wunsafe-loop-optimizations Wunsafe-loop-optimizations
......
...@@ -3722,6 +3722,15 @@ requiring a non-null value by the @code{nonnull} function attribute. ...@@ -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 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
can be disabled with the @option{-Wno-nonnull} option. 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)} @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
@opindex Winit-self @opindex Winit-self
@opindex Wno-init-self @opindex Wno-init-self
...@@ -4158,16 +4167,6 @@ In order to get a warning about an unused function parameter, you must ...@@ -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 either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
@option{-Wunused}), or separately specify @option{-Wunused-parameter}. @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 @item -Wuninitialized
@opindex Wuninitialized @opindex Wuninitialized
@opindex Wno-uninitialized @opindex Wno-uninitialized
......
...@@ -464,7 +464,9 @@ value of @option{-fmath-errno} for languages that do not use ...@@ -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 If not explicitly set, the option is set to the value of
@option{-@var{opt}}; multiple options can be given, separated by @option{-@var{opt}}; multiple options can be given, separated by
@code{||}. The third form using @code{&&} specifies that the option is @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}) @item LangEnabledBy(@var{language}, @var{opt})
@itemx LangEnabledBy(@var{language}, @var{opt}, @var{posarg}, @var{negarg}) @itemx LangEnabledBy(@var{language}, @var{opt}, @var{posarg}, @var{negarg})
......
...@@ -324,7 +324,7 @@ function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enab ...@@ -324,7 +324,7 @@ function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enab
} else if (enabledby_posarg == "" && enabledby_negarg == "") { } else if (enabledby_posarg == "" && enabledby_negarg == "") {
with_args = "" with_args = ""
} else { } else {
print "#error LangEnabledBy("enabledby_langs","enabledby_name", " \ print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \
enabledby_posarg", " enabledby_negargs \ enabledby_posarg", " enabledby_negargs \
") with three arguments, it should have either 2 or 4" ") 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 ...@@ -333,8 +333,8 @@ function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enab
for (k = 1; k <= n_enabledby_array; k++) { for (k = 1; k <= n_enabledby_array; k++) {
enabledby_index = opt_numbers[enabledby_array[k]]; enabledby_index = opt_numbers[enabledby_array[k]];
if (enabledby_index == "") { if (enabledby_index == "") {
print "#error LangEnabledBy("enabledby_langs","enabledby_name", " \ print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \
enabledby_posarg", " enabledby_negargs") has invalid ENABLEDBY_NAME" enabledby_posarg", " enabledby_negargs"), unknown option '" enabledby_name "'"
} else { } else {
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]);
......
...@@ -30,7 +30,21 @@ ...@@ -30,7 +30,21 @@
# Dump that array of options into a C file. # Dump that array of options into a C file.
END { 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; n_enabledby = 0;
for (i = 0; i < n_langs; i++) { for (i = 0; i < n_langs; i++) {
n_enabledby_lang[i] = 0; n_enabledby_lang[i] = 0;
...@@ -48,15 +62,19 @@ for (i = 0; i < n_opts; i++) { ...@@ -48,15 +62,19 @@ for (i = 0; i < n_opts; i++) {
} }
n_enabledby_names = split(enabledby_arg, enabledby_names, split_sep); n_enabledby_names = split(enabledby_arg, enabledby_names, split_sep);
if (logical_and != 0 && n_enabledby_names > 2) { 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++) { for (j = 1; j <= n_enabledby_names; j++) {
enabledby_name = enabledby_names[j]; enabledby_name = enabledby_names[j];
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 " opts[i] " Enabledby(" enabledby_name "), unknown option '" enabledby_name "'"
} else { } else if (!flag_set_p("Common", merged_flags[enabledby_index])) {
condition = ""; 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) { if (logical_and != 0) {
opt_var_name_1 = search_var_name(enabledby_names[1], opt_numbers, opts, flags, n_opts); 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); opt_var_name_2 = search_var_name(enabledby_names[2], opt_numbers, opts, flags, n_opts);
......
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