cgen: use `c_name()` for escaping goto label names too

pull/12799/head
Delyan Angelov 2021-12-11 19:41:44 +02:00
parent 9e68a03f94
commit fe14e2fceb
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 5 additions and 5 deletions

View File

@ -93,7 +93,7 @@ pub fn gamma(a f64) f64 {
for x < 0 { for x < 0 {
if x > -1e-09 { if x > -1e-09 {
unsafe { unsafe {
goto small_ goto small
} }
} }
z = z / x z = z / x
@ -102,7 +102,7 @@ pub fn gamma(a f64) f64 {
for x < 2 { for x < 2 {
if x < 1e-09 { if x < 1e-09 {
unsafe { unsafe {
goto small_ goto small
} }
} }
z = z / x z = z / x
@ -119,7 +119,7 @@ pub fn gamma(a f64) f64 {
if true { if true {
return z * p / q return z * p / q
} }
small_: small:
if x == 0 { if x == 0 {
return inf(1) return inf(1)
} }

View File

@ -1675,11 +1675,11 @@ fn (mut g Gen) stmt(node ast.Stmt) {
g.global_decl(node) g.global_decl(node)
} }
ast.GotoLabel { ast.GotoLabel {
g.writeln('$node.name: {}') g.writeln('${c_name(node.name)}: {}')
} }
ast.GotoStmt { ast.GotoStmt {
g.write_v_source_line_info(node.pos) g.write_v_source_line_info(node.pos)
g.writeln('goto $node.name;') g.writeln('goto ${c_name(node.name)};')
} }
ast.HashStmt { ast.HashStmt {
mut ct_condition := '' mut ct_condition := ''