[cfe-commits] Note and FixIt for additional case of vexing parse

Richard Smith richard at metafoo.co.uk
Tue Jul 24 12:36:34 PDT 2012


On Tue, Jul 24, 2012 at 8:11 AM, Nikola Smiljanic <popizdeh at gmail.com>wrote:

> > * If the return type is a reference, do not warn if the function has no
> > arguments.
>
> Aren't you missing a case when there is more than one argument?
>

That's covered by the next bullet.


> int& foo(); // must be a function declaration, references can't be
> uninitialized
> int& foo(bar); // ambiguous, could be a variable initialization
> int& foo(bar, baz); // again must be a function declaration, because
> otherwise this code wouldn't make sense
>
> I feel like the warning should be emitted when the return type is a
> reference AND the function has only one argument? Maybe we can do even
> better by checking if this single argument is convertible to reference
> type, but this might be too much.


We don't have an argument expression, so deducing the argument type might
be tricky. I don't think this is necessary.


> > * If the return type is not a class type, do not warn if the function has
> > more than one argument.
>
> I'm not sure I understand this. Why shouldn't we warn on something like
> this?
>
> int foo(int(), int());
>

Because that could never be valid as an initializer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120724/21ad0095/attachment.html>


More information about the cfe-commits mailing list