Fix detection of labels with a typedef name
This needs to be accepted:
typedef int foo;
void f (void) { foo: return; }
namespaces for labels and types are different. The problem is that
the block parser always tries to find a decl first and that routine
doesn't peek enough to detect this case. Needs some adjustments
to unget_tok() so that we can call it even when we already called
it once, but next() didn't come around restoring the buffer yet.
(It lazily does so not when the buffer becomes empty, but rather
when the next call detects that the buffer is empty, i.e. it requires
two next() calls until the unget buffer gets switched back).
This commit is contained in:
@ -432,6 +432,7 @@ void loop_test()
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
typedef int typedef_and_label;
|
||||
|
||||
void goto_test()
|
||||
{
|
||||
@ -440,6 +441,8 @@ void goto_test()
|
||||
|
||||
printf("goto:\n");
|
||||
i = 0;
|
||||
/* This needs to parse as label, not as start of decl. */
|
||||
typedef_and_label:
|
||||
s_loop:
|
||||
if (i >= 10)
|
||||
goto s_end;
|
||||
|
||||
Reference in New Issue
Block a user