Skip to content
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

Error for GNU-style inline assembly #572

Open
zyedidia opened this issue Nov 3, 2022 · 2 comments
Open

Error for GNU-style inline assembly #572

zyedidia opened this issue Nov 3, 2022 · 2 comments

Comments

@zyedidia
Copy link

zyedidia commented Nov 3, 2022

Formatting this code causes an error and warning:

void write(Reg reg)(uintptr val) {
    asm {
        "csrw %0, %1" : : "i"(reg) "r"(val);
    }
}
test.d(3:36)[error]: Expected `;` instead of `"r"`
test.d(3:44)[warn]: Empty asm instruction

even though this is valid code in GDC/LDC (for the right target). Maybe there should be an option to disable formatting within asm blocks and it can just ignore them?

It still formats the code, so it's not really a problem, but it's annoying that it spits out an error and warning.

@zyedidia
Copy link
Author

zyedidia commented Nov 3, 2022

I guess I am supposed to add a comma after the first argument: "i"(reg), "r"(val). It's interesting that gdc still accepts it without the comma. Sorry for the bother.

@zyedidia zyedidia closed this as completed Nov 3, 2022
@WebFreak001
Copy link
Member

WebFreak001 commented Nov 3, 2022

if GDC accepts it, so should dfmt / libdparse

@WebFreak001 WebFreak001 reopened this Nov 3, 2022
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

No branches or pull requests

2 participants