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

Andrew,

I tried the patch, but I still have the same problem. I added my comments to the 77154 bug.

jason

On Nov 1, 2004, at 17:01, Andrew Niefer wrote:





Hi Jason,
I believe that the problem you're describing is an instance of bug 77154,
where we are allowing a postfix expression with an empty LHS.
Which results in cast expression that don't make sense.
I would suggest adding your comments to that bug. Also, there is currently a patch attached to that bug which you might want to try to see if it fixes
your problem.

-Andrew

cdt-dev-admin@xxxxxxxxxxx wrote on 11/01/2004 10:54:25 AM:

john,

I'll put the bug in today, apologies for the delay.

In the meantime I think I discovered another problem, let me know what
you think.  Parsing the following program

int main(int argc, char *argv[])
{
   unsigned long l = 0;
   char *c;

   l |= ((unsigned long)(*((c)++)))<<24;
}

results in the sub-expression (c)++ being a cast of ++ with the type
(c).

jason



On Oct 28, 2004, at 15:52, John Camelon wrote:


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

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-dev




Back to the top