PING: [PATCH: c++/diagnostic/18313] Warn for pointless qualifiers on return type
Dirk Mueller
dmuell@gmx.net
Sun Nov 12 23:35:00 GMT 2006
On Sunday, 12. November 2006 22:27, Mark Mitchell wrote:
> sense for that specific instantiation. Here, I think we should warn at
> instantiation-time, since, in the presence of dependent types, we don't
> what's a class, or what the cv-qualification may be.
But why would you want to spill out hundreds of warnings from STL container
classes to the user just because he decided to use an instantiation with an
integral data type? Seems wrong to me. It is perfectly fine for the STL
container classes to be used in such a way, and I think the wisest is to
suppress the warning if in doubt.
> However, as I understand it, your code won't warn about even:
You're right. I'm testing the following patch now, ok if bootstrapping and
regtesting passes?
--- cp/decl.c (revision 118339)
+++ cp/decl.c (working copy)
@@ -7528,9 +7528,15 @@ grokdeclarator (const cp_declarator *dec
/* Declaring a function type.
Make sure we have a valid type for the function to return. */
- /* We now know that the TYPE_QUALS don't apply to the
- decl, but to its return type. */
- type_quals = TYPE_UNQUALIFIED;
+ if (type_quals != TYPE_UNQUALIFIED)
+ {
+ if (!IS_AGGR_TYPE (type) && !CLASS_TYPE_P (type))
+ warning (OPT_Wreturn_type,
+ "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. */
+ type_quals = TYPE_UNQUALIFIED;
+ }
/* Warn about some types functions can't return. */
Dirk
More information about the Gcc-patches
mailing list