1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: keep volatile qualifier in global declarations (#15947)

This commit is contained in:
Swastik Baranwal 2022-10-02 13:20:16 +05:30 committed by GitHub
parent a7ad64033e
commit 8a38bc2324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -1103,6 +1103,9 @@ pub fn (mut f Fmt) global_decl(node ast.GlobalDecl) {
}
for field in node.fields {
f.comments(field.comments, inline: true)
if field.is_volatile {
f.write('volatile ')
}
f.write('$field.name ')
f.write(strings.repeat(` `, max - field.name.len))
if field.has_expr {

View File

@ -1,3 +1,7 @@
struct TestInt {
i int
}
__global x = bool(true)
__global y f32
__global ()
@ -6,5 +10,8 @@ __global (
foo = int(5)
)
__global (
a int
a int
volatile test_int = TestInt{
i: 0
}
)