[cfe-commits] r127460 - in /cfe/trunk: lib/Sema/SemaType.cpp test/SemaCXX/return.cpp
Johannes Schaub (litb)
schaub.johannes at googlemail.com
Fri Mar 11 08:17:36 PST 2011
Rafael Avila de Espindola wrote:
>> If we want to warn on extraneous qualifiers for conversions functions, I
>> feel like that should be a separate warning tailored to the situation.
>> Calling it a 'return type' is a bit confusing.
>
> True. Also, is the const in
>
> class foo {
> operator int * const ();
> };
>
> really redundant? Are there cases where that operator would be selected
> but one without a const would not?
>
It's not redundant in the sense that you can omit it to create an equivalent
program. It's redundant with regard to the return value it yields.
If you do "&foo::operator int *const", then you get a "int * const(foo::*)
()". If you remove the "const", then you get a "int*(foo::*)()". Meaning, it
*does* affect the type/return type of the conversion function (as is the
case for other functions too).
However, calling it will yield an rvalue of type "int*", therefor it won't
change the type of a function call. Maybe warning "'const' type qualifier
has no effect on function return value" would be more accurate, even if
still (IMO) slightly ambiguous.
More information about the cfe-commits
mailing list