(All the preprocessor stuff will have been removed by the time the compiler sees it)
Code: Select all
void just_some_function(int some_param) // <=== forgot ;
void some_other_function(int some_param)
{ // <=== syntax error report on '{'
// blabla
}
Looks odd that it would parse all the way over two function prototypes. Is that valid C syntax?
Anyway, this one took me several hours to track down because the error report had nothing to do with the location of the actual error.
I was giving it a little leeway because C is also supposed to accept the old K&R function prototypes as in:
Code: Select all
void func(a,b,c)
int a;
char b;
long c;
{
...
}
So a missing semi-colon as in your example may cause the scanner to look through a following K&R parameter declaration like "void some_other_function(int some_param)" before reporting an error. This list bit is not a valid parameter declaration but it won't known that until it sees the function syntax.
But then I tried this:
Code: Select all
void just_some_function(int some_param) // <=== forgot ;
int a;
void some_other_function(int some_param)
{ // <=== syntax error report on '{'
// blabla
}
And the error is still not reported until "void some_other_function(int some_param)". The compiler went through the "int a" but it should be able to see there that the "a" does not match a parameter name in the function prototype's parameter list.
I think this is just reflection of the current state of sdcc's support for K&R syntax. It doesn't support K&R declarations as of now but I think it's scanner does recognize it so we get this halfway acceptance. The scanner knows that an "int a" could be a K&R parameter declaration but the parser/compiler doesn't know about K&R so can't generate an error at the right place.
I'll make a bug report for this at sdcc and see if they want to look at it. The K&R syntax has been on their to-do list for a long time so I don't know if they'd rather just wait for that to be done instead of fixing this.