Skip to content

Conversation

@xavierleroy
Copy link
Contributor

@xavierleroy xavierleroy commented Dec 2, 2024

As a popular extension to ISO C, CompCert C supports identifiers starting with $. In the generated assembly code, identifiers such as $123 can be confused for integer literals. That's the case for x86 (see #540) and for 32-bit ARM.

This PR fixes the issue like GCC does, by enclosing identifiers starting with $ in parentheses. Note that this is not necessary for macOS, since all C identifiers are prefixed by _, making _$123 unambiguous.

The ARM assembly language reference manual suggests the use of vertical bars |$123|, but these are not implemented by the GNU assembler.

A test was added to the small test suite.

Fixes: #540

They must be parenthesized in some contexts to avoid being confused for
immediate operands.

Fixes: #540
They must be parenthesized in some contexts.
@xavierleroy xavierleroy merged commit d4c6a8c into master Dec 6, 2024
6 of 7 checks passed
@xavierleroy xavierleroy deleted the dollar-ident branch December 6, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compilation fails at assembling due to "juk after expression"

2 participants