PING: [PATCH: c++/diagnostic/18313] Warn for pointless qualifiers on return type

Dirk Mueller dmuell@gmx.net
Mon Nov 13 09:34:00 GMT 2006


On Monday, 13. November 2006 00:48, Mark Mitchell wrote:

> We generally don't warn about system headers, so STL itself is probably
> not a problem.

Ok, but this will be a problem with other template container class collections 
(boost, Qt, ...). 

> My tentative inclination is that we should warn -- because anything else
> is too complicated -- and that users can use fine-grained warning
> control to turn off warnings where spurious.

This is a warning which is enabled by default (with -Wall), so I wanted to 
reduce the noise. But point taken. To understand things correctly: 

template<typename T> class Pair
{
    public:
        ....
        T getLeft() const;
        const T getRight() const;
};


when there is a Pair<const int> instantiation, you want calls of "getLeft" to 
warn? How about "getRight" (in the <const int> case, and in the <int> case)?
I want to suppress warnings for getRight() otherwise it produces false 
positives for code that was written with item 43 of Herb Sutter Exceptional 
C++ in mind. I'll try if I can implement this subtle semantic.

> Second:
> > +               if (!IS_AGGR_TYPE (type) && !CLASS_TYPE_P (type))
> is not a good expression of what you're trying to check.  CLASS_TYPE_P
> things are always IS_AGGR_TYPE, so once you've checked !IS_AGGR_TYPE,
> you've already checked !CLASS_TYPE_P.

Ok. Main reason for IS_AGGR_TYPE is that it checks for template type 
parameters. 

> I think maybe SCALAR_TYPE_P is what you're looking for?

"const void dofoo();" fails SCALAR_TYPE_P. 


Dirk



More information about the Gcc-patches mailing list