Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7f7ce3d

Browse filesBrowse files
authored
Merge pull request #852 from github/lcartey/m5-3-1-unevaluated-uninstantiated
M5-3-1: Exclude unknown types
2 parents 3720495 + 1af6957 commit 7f7ce3d
Copy full SHA for 7f7ce3d

File tree

3 files changed

+17
-1
lines changed
Filter options

3 files changed

+17
-1
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `M5-3-1` - `EachOperandOfTheOperatorOfTheLogicalAndOrTheLogicalOperatorsShallHaveTypeBool.ql`:
2+
- Consistently exclude results in unevaluated contexts associated with uninstantiated templates, for example `noexcept` specifiers and `static_assert`s.

‎cpp/autosar/src/rules/M5-3-1/EachOperandOfTheOperatorTheLogicalAndOrTheLogicalOperatorsShallHaveTypeBool.ql

Copy file name to clipboardExpand all lines: cpp/autosar/src/rules/M5-3-1/EachOperandOfTheOperatorTheLogicalAndOrTheLogicalOperatorsShallHaveTypeBool.ql
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ where
2525
) and
2626
t = operand.getType() and
2727
not t.getUnderlyingType().getUnspecifiedType() instanceof BoolType and
28+
// Ignore cases where the type is unknown - this will typically be in unevaluated contexts
29+
// within uninstantiated templates. It's necessary to check for this explicitly because
30+
// not all unevaluated contexts are considered to be `isFromUninstantiatedTemplate(_)`,
31+
// e.g. `noexcept` specifiers
32+
not t instanceof UnknownType and
2833
not exists(ReferenceType rt |
2934
rt = t.getUnderlyingType().getUnspecifiedType() and rt.getBaseType() instanceof BoolType
3035
) and

‎cpp/autosar/test/rules/M5-3-1/test.cpp

Copy file name to clipboardExpand all lines: cpp/autosar/test/rules/M5-3-1/test.cpp
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@ template <typename T = int> class A {
2525
void f() {
2626
A<int> a;
2727
a.test1();
28-
}
28+
}
29+
30+
template <typename T> constexpr bool some_variable_template_v = false;
31+
template <> constexpr bool some_variable_template_v<int> = true;
32+
33+
template <typename S>
34+
void template_with_no_except() noexcept(some_variable_template_v<S> &&
35+
true) { // COMPLIANT
36+
}
37+
void test_template() { template_with_no_except<int>(); }

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.