Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7f7ce3d

Browse files
authored
Merge pull request#852 from github/lcartey/m5-3-1-unevaluated-uninstantiated
M5-3-1: Exclude unknown types
2 parents3720495 +1af6957 commit7f7ce3d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed
Lines 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‎

Lines 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
nott.getUnderlyingType().getUnspecifiedType()instanceofBoolTypeand
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+
nottinstanceofUnknownTypeand
2833
notexists(ReferenceTypert|
2934
rt=t.getUnderlyingType().getUnspecifiedType()andrt.getBaseType()instanceofBoolType
3035
)and

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@ template <typename T = int> class A {
2525
voidf() {
2626
A<int> a;
2727
a.test1();
28-
}
28+
}
29+
30+
template<typename T>constexprbool some_variable_template_v =false;
31+
template<>constexprbool some_variable_template_v<int> =true;
32+
33+
template<typename S>
34+
voidtemplate_with_no_except()noexcept(some_variable_template_v<S> &&
35+
true) {// COMPLIANT
36+
}
37+
voidtest_template() { template_with_no_except<int>(); }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp