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 3fb6ac2

Browse filesBrowse files
authored
Merge pull request #636 from knewbury01/knewbury01/fix-621
A7-1-1: improve template handling
2 parents 1fd5675 + 652356b commit 3fb6ac2
Copy full SHA for 3fb6ac2

File tree

Expand file treeCollapse file tree

3 files changed

+13
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+13
-2
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A7-1-1` - `DeclarationUnmodifiedObjectMissingConstSpecifier.ql`:
2+
- Fixes #621. Exclude template instantiations that come from constexpr templates.

‎cpp/autosar/src/rules/A7-1-1/DeclarationUnmodifiedObjectMissingConstSpecifier.ql

Copy file name to clipboardExpand all lines: cpp/autosar/src/rules/A7-1-1/DeclarationUnmodifiedObjectMissingConstSpecifier.ql
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@ where
3737
) and
3838
not exists(LambdaExpression lc | lc.getACapture().getField() = v) and
3939
not v.isFromUninstantiatedTemplate(_) and
40-
not v.isCompilerGenerated()
40+
not v.isCompilerGenerated() and
41+
//if the instantiation is not constexpr but the template is, still exclude it as a candidate
42+
not exists(TemplateVariable b | b.getAnInstantiation() = v and b.isConstexpr())
4143
select v, "Non-constant variable " + v.getName() + cond + " and is not modified."

‎cpp/autosar/test/rules/A7-1-1/test.cpp

Copy file name to clipboardExpand all lines: cpp/autosar/test/rules/A7-1-1/test.cpp
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,11 @@ int main(int, char **) noexcept {
7676
new A7_1_1b<A7_1_1bHelper>(0);
7777

7878
(new Issue18)->F(0);
79-
}
79+
}
80+
81+
template <bool... Args> extern constexpr bool recurse_var = true; // COMPLIANT
82+
83+
template <bool B1, bool... Args>
84+
extern constexpr bool recurse_var<B1, Args...> = B1 &&recurse_var<Args...>;
85+
86+
void fp_621() { recurse_var<true, true, true>; }

0 commit comments

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