Skip to content

Commit 642ec38

Browse files
authored
Merge pull request #17340 from hvitved/csharp/ssa-exclude-enums
2 parents 89c387c + 4ef4ede commit 642ec38

File tree

2 files changed

+19
-1
lines changed
  • csharp/ql

2 files changed

+19
-1
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ private module SourceVariableImpl {
108108
*/
109109
predicate isPlainFieldOrPropAccess(FieldOrPropAccess fpa, FieldOrProp fp, Callable c) {
110110
fieldOrPropAccessInCallable(fpa, fp, c) and
111-
(ownFieldOrPropAccess(fpa) or fp.isStatic())
111+
(
112+
ownFieldOrPropAccess(fpa)
113+
or
114+
fp.isStatic() and not fp instanceof EnumConstant
115+
)
112116
}
113117

114118
/**
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
enum E
2+
{
3+
A
4+
}
5+
6+
class EnumTest
7+
{
8+
void M()
9+
{
10+
// enums are modelled as fields; this test checks that we do not compute SSA for them
11+
var e1 = E.A;
12+
var e2 = E.A;
13+
}
14+
}

0 commit comments

Comments
 (0)