Make Warray-bounds alias to Warray-bounds= [PR107787]

According to the documentation, the -Werror= option makes the specified
warning into an error and also automatically implies that option. Then
it seems that the behavior of the compiler when specifying
-Werror=array-bounds=X should be the same as specifying
"-Werror=array-bounds -Warray-bounds=X", so we expect to receive
array-bounds pass diagnostics and they must be processed as errors.

In practice, we observe that the array-bounds pass is indeed invoked,
but its diagnostics are processed as warnings, not errors.

This happens because Warray-bounds and Warray-bounds= are
declared as two different options in common.opt, so when
diagnostic_classify_diagnostic is called, DK_ERROR is set for
the Warray-bounds= option, but diagnostic_report_diagnostic called from
warning_at receives opt_index of Warray-bounds, so information about
DK_ERROR is lost. Fix this by using Alias in declaration of
Warray-bounds (similar to Wattribute-alias).

Co-authored-by: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>

gcc/ChangeLog:

	PR driver/107787
	* common.opt (Warray-bounds): Turn into alias of
	-Warray-bounds=1.
	* builtins.cc (c_strlen): Use OPT_Warray_bounds_
	instead of OPT_Warray_bounds.
	* diagnostic-spec.cc (nowarn_spec_t::nowarn_spec_t): Ditto.
	* gimple-array-bounds.cc (array_bounds_checker::check_array_ref,
	array_bounds_checker::check_mem_ref,
	array_bounds_checker::check_addr_expr,
	array_bounds_checker::check_array_bounds): Ditto.
	* gimple-ssa-warn-restrict.cc (maybe_diag_access_bounds): Ditto.

gcc/c-family/ChangeLog:

	PR driver/107787
	* c-common.cc (fold_offsetof,
	convert_vector_to_array_for_subscript): Use OPT_Warray_bounds_
	instead of OPT_Warray_bounds.

gcc/testsuite/ChangeLog:

	PR driver/107787
	* gcc.dg/Warray-bounds-34.c: Correct the regular expression
	for -Warray-bounds=.
	* gcc.dg/Warray-bounds-43.c: Likewise.
	* gcc.dg/pr107787.c: New test.
9 files changed