diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll index 8fd12d90ae7a..d4f0625be88c 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll @@ -108,7 +108,11 @@ private module SourceVariableImpl { */ predicate isPlainFieldOrPropAccess(FieldOrPropAccess fpa, FieldOrProp fp, Callable c) { fieldOrPropAccessInCallable(fpa, fp, c) and - (ownFieldOrPropAccess(fpa) or fp.isStatic()) + ( + ownFieldOrPropAccess(fpa) + or + fp.isStatic() and not fp instanceof EnumConstant + ) } /** diff --git a/csharp/ql/test/library-tests/dataflow/ssa/Enum.cs b/csharp/ql/test/library-tests/dataflow/ssa/Enum.cs new file mode 100644 index 000000000000..283b28000983 --- /dev/null +++ b/csharp/ql/test/library-tests/dataflow/ssa/Enum.cs @@ -0,0 +1,14 @@ +enum E +{ + A +} + +class EnumTest +{ + void M() + { + // enums are modelled as fields; this test checks that we do not compute SSA for them + var e1 = E.A; + var e2 = E.A; + } +}