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

Nikola Smiljanic popizdeh at gmail.com
Tue Jul 24 08:11:03 PDT 2012


> * 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?

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.

> * 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());



More information about the cfe-commits mailing list