Skip to content

Commit

Permalink
fix rule for const task private vars
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 committed Sep 27, 2024
1 parent 1de6c81 commit 0ecd373
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions test/chplcheck/UnusedTaskIntent.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ module UnusedTaskIntent {
@chplcheck.ignore("UnusedTaskIntent")
[1..10 with(ref A)] { ; }

forall 1..10 with (const A) { }
forall 1..10 with (const x: int) { }
forall 1..10 with (const x = 1) { }
}
1 change: 1 addition & 0 deletions test/chplcheck/UnusedTaskIntent.good
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ UnusedTaskIntent.chpl:22: node violates rule UnusedTaskIntent
UnusedTaskIntent.chpl:24: node violates rule UnusedTaskIntent
UnusedTaskIntent.chpl:26: node violates rule UnusedTaskIntent
UnusedTaskIntent.chpl:27: node violates rule UnusedTaskIntent
UnusedTaskIntent.chpl:32: node violates rule UnusedTaskIntent
[Success matching fixit for UnusedTaskIntent]
3 changes: 3 additions & 0 deletions test/chplcheck/UnusedTaskIntent.good-fixit
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ module UnusedTaskIntent {
@chplcheck.ignore("UnusedTaskIntent")
[1..10 with(ref A)] { ; }

forall 1..10 { }
forall 1..10 with (const x: int) { }
forall 1..10 with (const x = 1) { }
}
13 changes: 10 additions & 3 deletions tools/chplcheck/src/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,16 @@ def UnusedTaskIntent(context: Context, root: AstNode):
for intent, _ in chapel.each_matching(
root, set([TaskVar, ReduceIntent])
):
# var intents may have side effects, so we don't want to warn on them
if isinstance(intent, TaskVar) and intent.intent() == "var":
continue
# task private variables may have side effects,
# so we don't want to warn on them
if isinstance(intent, TaskVar):
if intent.intent() == "var":
continue
if intent.intent() == "<const-var>" and (
intent.type_expression() is not None
or intent.init_expression() is not None
):
continue
intents[intent.unique_id()] = intent

for use, _ in chapel.each_matching(root, Identifier):
Expand Down

0 comments on commit 0ecd373

Please sign in to comment.