You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a label exists in a configuration, the configuration duplicates the label with the same name twice. If both labels exist in the same scope, this causes an error. For example:
char
foo()
{
int x;
goto label;
label:
x +=
#ifdef A
2
#else
3
#endif
;
}
which will throw this error:
gotoTest.desugared.c: In function ‘__foo_0’:
gotoTest.desugared.c:33:1: error: duplicate label ‘label’
label : __x_1 += 3 ;
^~~~~
gotoTest.desugared.c:28:1: note: previous definition of ‘label’ was here
label : __x_1 += 2 ;
^~~~~
The text was updated successfully, but these errors were encountered:
Solving this requires a few things in order to still desugar in a single pass:
The existing symbol table can be used to store labels by putting them in a different namespace (the label namespace is separate from both tags and regular symbols).
A goto may appear before the label itself. Since the label itself may be duplicated during desugaring, there is no way in a single pass to know the renamings ahead of time. What can be done to maintain a single pass is to create a level of indirection: create a fresh label, then when all labels have been collected and renamed by the end of the function, create a special code section that dispatches the goto label to the correct label renaming based on static conditionals.
Without allowing multiple passes or rearchitecting the output data structure, this is what the single-pass approach might look like
goto label;
//...
label: // ...
//...
label: // in another configuration
When a label exists in a configuration, the configuration duplicates the label with the same name twice. If both labels exist in the same scope, this causes an error. For example:
transforms into:
which will throw this error:
gotoTest.desugared.c: In function ‘__foo_0’:
gotoTest.desugared.c:33:1: error: duplicate label ‘label’
label : __x_1 += 3 ;
^~~~~
gotoTest.desugared.c:28:1: note: previous definition of ‘label’ was here
label : __x_1 += 2 ;
^~~~~
The text was updated successfully, but these errors were encountered: