Open jrrrp opened 4 years ago
Could you clarify what you mean by unnamed or abstract parameters?
I don't believe these are valid C. Everything that is in ANSI C89 could be tested, except for the features that were explicitly listed shouldn't be supported.
@jrpdotjpg an example would be helpful :octocat:
Yes sorry, the question wasn't exactly clear. I meant to say will function declarations like int func(int)
be tested, which I'm pretty sure are in C90.
This is completely valid and would look like this:
We just need a confirmation if this is to be implemented (as it would complicate things in the function definition / declaration)
Yes it's valid, but will it be tested?
These are old C-style function declarations, which are not going to be tested according to spec if I remember correctly.
K&R are different to this, they just have identifiers without types
Update: according to the C grammar, it is valid. According to this online compiler, the following code will not compile:
int f(int ){
return 3;
}
int main()
{
return f(3);
}
Ah, seems these are just to be used with function prototypes:
int f(int);
So basically a valid code is:
int f(int);
int main(){return f(3);}
int f(int x){return x;}
It compiles. It also doesn't differ at all from implementing the following on both the parsing and assembly generation levels (just make the identifier optional):
int f(int x);
int main(){return f(3);}
int f(int x){return x;}
I would say make the rule:
spec=declarationSpecifiers dec=abstractDeclarator?
and since you know it's valid input, dec will always be there during a definition (you can still check if the node is null). You also will never need dec when declaring the function, only the type and the order of the types is necessary
Yes, function prototypes could be tested. Unnamed parameters in function definitions are not valid C90 so should not be supported.
What about function declarations that don't give any information about the parameters.
The following would be valid c
int foo();
int main(){ return foo(7, 'a'); }
int foo(int x, char c) { return x; }
I would say you can assume that prototypes will actually match up with their declarations and contain the type information.
They're not explicitly listed but I might as well check: are unnamed parameters to be implemented? Ie abstract parameters.
Edit: And also with this the whole idea of abstract declarators?