summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordougkwan <dougkwan@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-13 00:22:38 +0000
committerdougkwan <dougkwan@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-13 00:22:38 +0000
commit36e37a8772797c12053db9ddaeb88e728996d815 (patch)
treee1ab0d8cbc735be34bf3b43df3a196670e70025b
parente0c9c00f8e3d73854993553257b6438b617989ab (diff)
downloadgcc-36e37a8772797c12053db9ddaeb88e728996d815.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131499 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/c-decl.c2
-rw-r--r--gcc/c-opts.c4
-rw-r--r--gcc/c.opt4
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/doc/invoke.texi24
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/warn/Wreturn-type-4.C2
-rw-r--r--gcc/testsuite/gcc.dg/qual-return-1.c2
11 files changed, 56 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a3370c4c40b..9595419ad80 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 033ff2eec49..9237a75491a 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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);
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index 3c6219265cd..951118c51b5 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -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. */
diff --git a/gcc/c.opt b/gcc/c.opt
index 37c55bedadf..37045197bf1 100644
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -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
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8a6c34135fd..c46c07251a4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f968e88c0c5..11a5c478fbe 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9f87778fc44..f25f2c40304 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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. */
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 177e007db11..5e41ec30f51 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1c7ec62cac6..34b4ec11580 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-4.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-4.C
index dbb089b1812..20c34a836a9 100644
--- a/gcc/testsuite/g++.dg/warn/Wreturn-type-4.C
+++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-4.C
@@ -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" } */
diff --git a/gcc/testsuite/gcc.dg/qual-return-1.c b/gcc/testsuite/gcc.dg/qual-return-1.c
index ac94df6d2bb..8151995d8b3 100644
--- a/gcc/testsuite/gcc.dg/qual-return-1.c
+++ b/gcc/testsuite/gcc.dg/qual-return-1.c
@@ -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. */