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 1963eed

Browse filesBrowse files
authored
Merge pull request #814 from fjatWbyT/exclude-rvaluerefs-a7-1-1
Exclude rvalue references from `const` in AUTOSAR rule 7-1-1.
2 parents 83e1a8b + 3a20ccc commit 1963eed
Copy full SHA for 1963eed

File tree

3 files changed

+16
-1
lines changed
Filter options

3 files changed

+16
-1
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+
- Exclude rvalue references.

‎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
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ where
3838
not exists(LambdaExpression lc | lc.getACapture().getField() = v) and
3939
not v.isFromUninstantiatedTemplate(_) and
4040
not v.isCompilerGenerated() and
41+
not v.getType() instanceof RValueReferenceType and
4142
//if the instantiation is not constexpr but the template is, still exclude it as a candidate
4243
not exists(TemplateVariable b | b.getAnInstantiation() = v and b.isConstexpr())
4344
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
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,16 @@ template <bool... Args> extern constexpr bool recurse_var = true; // COMPLIANT
8383
template <bool B1, bool... Args>
8484
extern constexpr bool recurse_var<B1, Args...> = B1 &&recurse_var<Args...>;
8585

86-
void fp_621() { recurse_var<true, true, true>; }
86+
void fp_621() { recurse_var<true, true, true>; }
87+
88+
#include <utility>
89+
90+
void variadic_forwarding() {}
91+
92+
template <typename T, typename... Args>
93+
void variadic_forwarding(T &&first, Args &&...rest) {
94+
first;
95+
variadic_forwarding(std::forward<Args>(rest)...);
96+
}
97+
98+
int test_variadic_forwarding() { variadic_forwarding(1, 1.1, "a"); }

0 commit comments

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