From: Doug Kwan Date: Sun, 13 Jan 2008 00:22:38 +0000 (+0000) Subject: c-decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers instead of OPT_Wreturn_type... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5db2e9ca7dc5ab9bac4baad91c224ba7d8fc0c45;p=platform%2Fupstream%2Fgcc.git c-decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers instead of OPT_Wreturn_type in... ChangeLog: 2008-01-12 Doug Kwan * 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 * 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 * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a3370c4..9595419 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2008-01-12 Doug Kwan + + * 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 PR ada/33788 diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 033ff2e..9237a75 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 3c62192..951118c 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 37c55be..3704519 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 8a6c341..c46c072 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2008-01-12 Doug Kwan + + * 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 PR c++/33890 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f968e88..11a5c47 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 9f87778..f25f2c4 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 177e007..5e41ec3 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 1c7ec62..34b4ec1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-01-12 Doug Kwan + + * 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 * 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 dbb089b..20c34a8 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 ac94df6..8151995 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 */ /* { 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. */