Skip to content

Commit 7361106

Browse files
committed
Exclude non-static members
Exclude non-static members from being marked as `constexpr`.
1 parent 9b4593b commit 7361106

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
`A7-1-2` - `VariableMissingConstexpr.ql`:
2-
- Fix FP reported in #466. Addresses incorrect assumption that calls to `constexpr` functions are always compile-time evaluated.
2+
- Fix FP reported in #466. Addresses incorrect assumption that calls to `constexpr` functions are always compile-time evaluated.
3+
- Exclude member that aren't `static`, because they cannot be `constexpr`.

cpp/autosar/src/rules/A7-1-2/VariableMissingConstexpr.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ where
8181
// Not assigned by a user in a constructor
8282
not exists(ConstructorFieldInit cfi | cfi.getTarget() = v and not cfi.isCompilerGenerated()) and
8383
// Ignore union members
84-
not v.getDeclaringType() instanceof Union
84+
not v.getDeclaringType() instanceof Union and
85+
// If it is a member, it must be static to be constexpr
86+
(v instanceof MemberVariable implies v.isStatic())
8587
select v, "Variable " + v.getName() + " could be marked 'constexpr'."

0 commit comments

Comments
 (0)