Skip to main content

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


What you have found, is most likely a bug.  
When an _expression_ is created, some semantic validation is done on the _expression_ to ensure that the operand types adhere to the spirit of the operation.
You have found a point where this is not done properly.  It most likely had not been detected up to this point as the only symptom is an IProblem or missed reference as compared to an ambiguity in the grammar.  

Please raise a defect.
Thanks
JohnC
www.eclipse.org/cdt


cdt-dev-admin@xxxxxxxxxxx wrote on 10/28/2004 04:20:27 AM:

> 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
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-dev

Back to the top