Skip to content

Commit d26148c

Browse files
committed
Fix inconsistency with linemark generation with assignments
This is a kludge; RAII will fix this more thoroughly through its write/assign_to revamp
1 parent b9b728c commit d26148c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

py/dml/ctree.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ def toc(self):
986986
self.toc_inline()
987987
out('}\n', preindent=-1)
988988
def toc_inline(self):
989+
self.linemark()
989990
self.initializer.assign_to(self.target, self.target.ctype())
990991

991992
mkAssignStatement = AssignStatement
@@ -4807,7 +4808,8 @@ def assign_to(self, dest, typ):
48074808
mkCast(site, self.expr, typ).read(),
48084809
dest.read()))
48094810
else:
4810-
mkCopyData(site, self.expr, dest).toc()
4811+
with disallow_linemarks():
4812+
mkCopyData(site, self.expr, dest).toc()
48114813

48124814
class CompoundInitializer(Initializer):
48134815
'''Initializer for a variable of struct or array type, using the

py/dml/expr.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
'typecheck_inargs',
2626
'reset_line_directive',
2727
'allow_linemarks',
28+
'disallow_linemarks',
2829
'site_linemark',
2930
'coverity_marker',
3031
'coverity_markers',
@@ -103,6 +104,16 @@ def allow_linemarks():
103104
if not prev_linemarks and is_file_output:
104105
reset_line_directive()
105106

107+
# Locally set dml.globals.linemarks to be False, even if it were already True
108+
@contextmanager
109+
def disallow_linemarks():
110+
prev_linemarks = dml.globals.linemarks
111+
dml.globals.linemarks = False
112+
try:
113+
yield
114+
finally:
115+
dml.globals.linemarks = prev_linemarks
116+
106117
def reset_line_directive():
107118
if dml.globals.linemarks_enabled:
108119
o = output.current()

0 commit comments

Comments
 (0)