[C++ Patch] PR 19966

Paolo Carlini pcarlini@suse.de
Thu Mar 17 13:30:00 GMT 2005


Hi everyone,

currently, for the testcase:

struct A
{
    static operator int();
};

19966.cc:3: error: 'static A::operator int()' must be a nonstatic member function
19966.cc:3: error: 'static A::operator int()' must take exactly one argument

and I agree that the second error message is confusing. We emit
it because the arity of the operator is computed as zero (no
this) and the checks involving the arity in the second half of
grok_op_properties all assume implicitly that a this argument
is present when it should.

In the patch below I propose to simply return early in such cases.
Seems, roughly, also the same behavior of the EDG front-end.

While working on the PR, I also noticed that nothing is using
the bool return value of grok_op_properties and took the 
liberty to change it to void, thus making the final result
a bit cleaner, IMO. I'm not sure if this is appropriate.

Tested x86-linux. Ok for mainline?

Paolo.

////////////////////


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_19966
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050317/cffa7b96/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_19966
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050317/cffa7b96/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: operator2.C
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050317/cffa7b96/attachment-0002.ksh>


More information about the Gcc-patches mailing list