[cfe-dev] C++ default arguments patch, rework Parse-Sema interaction for function parameters
Eli Friedman
eli.friedman at gmail.com
Sun Apr 6 15:50:14 PDT 2008
On Sun, Apr 6, 2008 at 10:24 AM, Doug Gregor <doug.gregor at gmail.com> wrote:
> You'll see a few new FIXMEs in this code that I haven't attacked yet.
> The most annoying one (for me) is that
>
> void f(int x, int y = x);
>
> doesn't actually produce an error.
Watch out here: there are other similar restrictions. For example,
the following is illegal:
void f()
{
int i;
extern void g(int x = sizeof(i));
}
Probably better to deal with this in Sema; any other behavior would
involve completely butchering scopes.
+ // Check for C99 6.7.5.3p10 - foo(void) is a non-varargs
+ // function that takes no arguments, not a function that takes a
+ // single void argument. FIXME: Is this really the right place
+ // to check for this? C++ says that the parameter list (void) is
+ // the same as an empty parameter list, whereas the parameter
+ // list (T) (with T typedef'd to void) is not. For C++, this
+ // should be handled in the parser. Check C89 and C99 standards
+ // to see what the correct behavior is.
AFAIK, clang currently handles C89/99 correctly for this case. Not
sure how this change affects that, though.
-Eli
More information about the cfe-dev
mailing list