c-decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers instead of OPT_Wreturn_type in...

ChangeLog:

2008-01-12  Doug Kwan  <dougkwan@google.com>

	* c-decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers
	instead of OPT_Wreturn_type in warning due to ignored return type
	qualifiers.
	* c-opt.c (c_common_post_option): Add -Wignored-qualifiers to
	options included in -Wextra.
	* c.opt: New option -Wignored_qualifiers.
	* doc/invoke.texi (Warning Options, -Wextra): Add new option
	-Wignore_qualifiers.
	(-Wignored-qualifiers): Document.
	(-Wreturn-type): Remove description of functionality now handled
	by -Wignored-qualifiers.

cp/ChangeLog:

2008-01-12  Doug Kwan  <dougkwan@google.com>

	* decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers
	instead of OPT_Wreturn_type in warning due to ignored return type
	qualifiers.
	* pt.c: (tsubst_function_type): Use OPT_Wignored_qualifiers
	instead of OPT_Wreturn_type in warning due to ignored return type
	qualifiers.

testsuite/ChangeLog:

2008-01-12  Doug Kwan  <dougkwan@google.com>

	* gcc.dg/qual-return-1.c: Add -Wignored-qualifiers.
	* g++.dg/warn/Wreturn-type-4.C: Replace -Wreturn-type by
	-Wignored-qualifiers.

From-SVN: r131499
This commit is contained in:
Doug Kwan 2008-01-13 00:22:38 +00:00 committed by Doug Kwan
parent 7219c2c7d3
commit 5db2e9ca7d
11 changed files with 56 additions and 15 deletions

View file

@ -1,3 +1,17 @@
2008-01-12 Doug Kwan <dougkwan@google.com>
* c-decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers
instead of OPT_Wreturn_type in warning due to ignored return type
qualifiers.
* c-opt.c (c_common_post_option): Add -Wignored-qualifiers to
options included in -Wextra.
* c.opt: New option -Wignored_qualifiers.
* doc/invoke.texi (Warning Options, -Wextra): Add new option
-Wignore_qualifiers.
(-Wignored-qualifiers): Document.
(-Wreturn-type): Remove description of functionality now handled
by -Wignored-qualifiers.
2008-01-12 Eric Botcazou <ebotcazou@adacore.com>
PR ada/33788

View file

@ -4526,7 +4526,7 @@ grokdeclarator (const struct c_declarator *declarator,
if (VOID_TYPE_P (type) && really_funcdef)
pedwarn ("function definition has qualified void return type");
else
warning (OPT_Wreturn_type,
warning (OPT_Wignored_qualifiers,
"type qualifiers ignored on function return type");
type = c_build_qualified_type (type, type_quals);

View file

@ -1064,7 +1064,7 @@ c_common_post_options (const char **pfilename)
/* -Wextra implies -Wtype-limits, -Wclobbered,
-Wempty-body, -Wsign-compare,
-Wmissing-field-initializers, -Wmissing-parameter-type
-Wold-style-declaration, and -Woverride-init,
-Wold-style-declaration, -Woverride-init and -Wignored-qualifiers
but not if explicitly overridden. */
if (warn_type_limits == -1)
warn_type_limits = extra_warnings;
@ -1082,6 +1082,8 @@ c_common_post_options (const char **pfilename)
warn_old_style_declaration = extra_warnings;
if (warn_override_init == -1)
warn_override_init = extra_warnings;
if (warn_ignored_qualifiers == -1)
warn_ignored_qualifiers = extra_warnings;
/* -Wpointer_sign is disabled by default, but it is enabled if any
of -Wall or -pedantic are given. */

View file

@ -242,6 +242,10 @@ Warn about zero-length formats
Wformat=
C ObjC C++ ObjC++ Joined Warning
Wignored-qualifiers
C C++ Var(warn_ignored_qualifiers) Init(-1) Warning
Warn whenever type qualifiers are ignored.
Winit-self
C ObjC C++ ObjC++ Var(warn_init_self) Warning
Warn about variables which are initialized to themselves

View file

@ -1,3 +1,12 @@
2008-01-12 Doug Kwan <dougkwan@google.com>
* decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers
instead of OPT_Wreturn_type in warning due to ignored return type
qualifiers.
* pt.c: (tsubst_function_type): Use OPT_Wignored_qualifiers
instead of OPT_Wreturn_type in warning due to ignored return type
qualifiers.
2008-01-08 Jakub Jelinek <jakub@redhat.com>
PR c++/33890

View file

@ -8018,7 +8018,7 @@ grokdeclarator (const cp_declarator *declarator,
if (type_quals != TYPE_UNQUALIFIED)
{
if (SCALAR_TYPE_P (type) || VOID_TYPE_P (type))
warning (OPT_Wreturn_type,
warning (OPT_Wignored_qualifiers,
"type qualifiers ignored on function return type");
/* We now know that the TYPE_QUALS don't apply to the
decl, but to its return type. */

View file

@ -8663,7 +8663,7 @@ tsubst_function_type (tree t,
&& in_decl != NULL_TREE
&& !TREE_NO_WARNING (in_decl)
&& (SCALAR_TYPE_P (return_type) || VOID_TYPE_P (return_type)))
warning (OPT_Wreturn_type,
warning (OPT_Wignored_qualifiers,
"type qualifiers ignored on function return type");
/* Construct a new type node and return it. */

View file

@ -236,7 +236,7 @@ Objective-C and Objective-C++ Dialects}.
-Werror -Werror=* @gol
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
-Wno-format-extra-args -Wformat-nonliteral @gol
-Wformat-security -Wformat-y2k @gol
-Wformat-security -Wformat-y2k -Wignored-qualifiers @gol
-Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol
-Wimport -Wno-import -Winit-self -Winline @gol
-Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
@ -2675,6 +2675,7 @@ name is still supported, but the newer name is more descriptive.)
@gccoptlist{-Wclobbered @gol
-Wempty-body @gol
-Wignored-qualifiers @gol
-Wmissing-field-initializers @gol
-Wmissing-parameter-type @r{(C only)} @gol
-Wold-style-declaration @r{(C only)} @gol
@ -2864,6 +2865,19 @@ enabled by default and it is made into an error by
Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
This warning is enabled by @option{-Wall}.
@item -Wignored-qualifiers
@opindex Wignored-qualifiers
@opindex Wno-ignored-qualifiers
Warn if the return type of a function has a type qualifier
such as @code{const}. For ISO C such a type qualifier has no effect,
since the value returned by a function is not an lvalue.
For C++, the warning is only emitted for scalar types or @code{void}.
ISO C prohibits qualified @code{void} return types on function
definitions, so such return types always receive a warning
even without this option.
This warning is also enabled by @option{-Wextra}.
@item -Wmain
@opindex Wmain
Warn if the type of @samp{main} is suspicious. @samp{main} should be a
@ -2996,14 +3010,6 @@ return-value in a function whose return-type is not @code{void}
without a value), and about a @code{return} statement with a
expression in a function whose return-type is @code{void}.
Also warn if the return type of a function has a type qualifier
such as @code{const}. For ISO C such a type qualifier has no effect,
since the value returned by a function is not an lvalue.
For C++, the warning is only emitted for scalar types or @code{void}.
ISO C prohibits qualified @code{void} return types on function
definitions, so such return types always receive a warning
even without this option.
For C++, a function without return type always produces a diagnostic
message, even when @option{-Wno-return-type} is specified. The only
exceptions are @samp{main} and functions defined in system headers.

View file

@ -1,3 +1,9 @@
2008-01-12 Doug Kwan <dougkwan@google.com>
* gcc.dg/qual-return-1.c: Add -Wignored-qualifiers.
* g++.dg/warn/Wreturn-type-4.C: Replace -Wreturn-type by
-Wignored-qualifiers.
2008-01-12 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/slice3.adb: New test.

View file

@ -1,6 +1,6 @@
/* PR c++/18313 */
/* { dg-do compile } */
/* { dg-options "-Wreturn-type" } */
/* { dg-options "-Wignored-qualifiers" } */
volatile void bar(); /* { dg-warning "type qualifiers ignored" } */

View file

@ -1,7 +1,7 @@
/* Test for warnings for qualified function return types. */
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wreturn-type" } */
/* { dg-options "-std=gnu99 -Wreturn-type -Wignored-qualifiers" } */
/* Qualifying a function return type makes no sense. */