Skip to content

Allow inline assembly #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 18, 2025
Merged

Allow inline assembly #293

merged 3 commits into from
Apr 18, 2025

Conversation

lumynou5
Copy link
Contributor

This patch is an attempt to enable inline assembly not being blocked by the checks.

Previously, fmtscan would report spelling in inline assembly and block committing, so an additional check is added to skip identifiers that are asm and contents in a pair of parentheses following them.

Also, Cppcheck cannot recognize the GNU extension of explicit register variables:

register int x asm("eax");

This patch suppresses syntax error to prevent explicit register variables being blocked. It also makes real syntax error suppressed, but it doesn't affect much while real ones lead to compile-time errors and can be found early.

@jserv
Copy link
Contributor

jserv commented Apr 17, 2025

Could your code handle all variations of inline assembly syntax found in GNU-compatible compilers like Clang, including asm, __asm, and __asm__?

@lumynou5
Copy link
Contributor Author

Could your code handle all variations of inline assembly syntax found in GNU-compatible compilers like Clang, including asm, __asm, and __asm__?

It can handle __asm__ now.

I didn't find any document of __asm except the very different syntax of MSVC.

@jserv
Copy link
Contributor

jserv commented Apr 17, 2025

I didn't find any document of __asm except the very different syntax of MSVC.

Simply search __asm inside GCC repository. It was a historical keyword.

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squash commits for reviewing.

Change-Id: If67148de2637a02fc44597700745056b846d7f32
Previously, fmtscan would report spelling in inline assembly and block
committing.

It supports the 'asm', '__asm__', and '__asm' keywords. According to the
GCC documentation, the 'asm' keyword is a GNU extension and the
alternative '__asm__' can be used when writing code compiled with
'-ansi' and various '-std' options, and '__asm' is a historical keyword
that the current documentation doesn't mention.

Closes: sysprog21#292
Change-Id: I9564c47a6ae67278a9b0c42ee0087d597c9c33ab
Cppcheck cannot recognize the GNU extension of explicit register
variables:
  register int x asm("eax");

This commit suppresses syntax error to prevent explicit register
variables being blocked. It also makes real syntax error suppressed, but
it doesn't affect much while real ones lead to compile-time errors and
can be found early.

Change-Id: I603fa80083ba935c7de706546f77bac616da6fcc
@jserv jserv merged commit 0b6f831 into sysprog21:master Apr 18, 2025
1 of 2 checks passed
@jserv
Copy link
Contributor

jserv commented Apr 18, 2025

Thank @lumynou5 for contributing!

@lumynou5 lumynou5 deleted the allow-inline-asm branch April 18, 2025 05:48
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.

2 participants