dlang-community / dfmt

Dfmt is a formatter for D source code
Boost Software License 1.0
204 stars 47 forks source link

Error for GNU-style inline assembly #572

Open zyedidia opened 1 year ago

zyedidia commented 1 year ago

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 commented 1 year ago

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.

WebFreak001 commented 1 year ago

if GDC accepts it, so should dfmt / libdparse