Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Apparent incorrect C parsing

Hi All,

Maybe I have done something horribly wrong, but I wanted to ask if anyone has seen this problem before. I see that it is possible to have the parser complete successfully a parse, but for the C file to be incorrect.

Here is the example it works on, but shouldn't

int main(int argc, char *argv[])
{
	m = 10;
	return 0;
}

however the following fails to parser correctly as expected, but the problem is not detected until the 'i' is reached.

int main(int argc, char *argv[])
{
	m = i;
	return 0;
}

I see that in the expression parser after trying to parse a cast, which is the last thing it tries a new name is created, but there does not appear to be a check that the name has been declared in the scope.

Here is another example that should cause a problem, but doesn't

int main(int argc, char *argv[])
{
			switch(loopvar)
			{
				int k = 2;
			default:
				printf("k = \n", k);
				break;
			}		
	return k;
}

Here there are two issues (initialiser for k) and k is not in scope in the return statement.

I'm using the latest version of the head of the cvs and i have been using ParserMode.COMPLETE_PARSE.

Any ideas as to what I am doing or I am assuming that I shouldn't be?

Jason



Back to the top