Skip to content

Commit 5097b5e

Browse files
authored
Merge branch 'master' into meilers_fix_782
2 parents 9e379cb + 5ecdc3c commit 5097b5e

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

src/main/scala/viper/silver/parser/MacroExpander.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,19 @@ object MacroExpander {
481481
freeVars += varUse.name
482482
(varUse, ctx)
483483
}
484+
case (label@PLabel(lbl, lName, invs), ctx) if !ctx.c.boundVars.contains(lName.name) =>
485+
if (ctx.c.paramToArgMap.contains(lName.name)) {
486+
val replacement = ctx.c.paramToArgMap(lName.name).deepCopyAll
487+
val replaced = replacement match {
488+
case r: PIdnUseExp => PIdnDef(r.name)(r.pos)
489+
case r =>
490+
throw MacroException(s"macro expansion cannot substitute expression `${replacement.pretty}` at ${replacement.pos._1} in non-expression position at ${lName.pos._1}.", replacement.pos)
491+
}
492+
(PLabel(lbl, replaced, invs)(label.pos), ctx.updateContext(ctx.c.copy(paramToArgMap = ctx.c.paramToArgMap.empty)))
493+
} else {
494+
freeVars += lName.name
495+
(label, ctx)
496+
}
484497
}, ReplaceContext())
485498
(replacer, freeVars)
486499
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
4+
5+
method main()
6+
{
7+
m(some_name)
8+
}
9+
10+
define m(label_name)
11+
{
12+
goto label_name
13+
label label_name
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
4+
5+
method main()
6+
{
7+
//:: ExpectedOutput(parser.error)
8+
m(3)
9+
}
10+
11+
define m(label_name)
12+
{
13+
label label_name
14+
}

0 commit comments

Comments
 (0)