Skip to content

Commit a00c620

Browse files
committed
A13-3-1: exclude functions with different number parameters
1 parent e1f822a commit a00c620

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`A13-3-1`: `cpp/autosar/function-that-contains-forwarding-reference-as-its-argument-overloaded`
2+
- Fixes #399. Exclude functions that have different number of parameters.

cpp/autosar/src/rules/A13-3-1/FunctionThatContainsForwardingReferenceAsItsArgumentOverloaded.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ where
2626
not isExcluded(f,
2727
OperatorsPackage::functionThatContainsForwardingReferenceAsItsArgumentOverloadedQuery()) and
2828
not f.isDeleted() and
29-
f = c.getAnOverload()
29+
f = c.getAnOverload() and
30+
//allow for overloading with different number of parameters
31+
f.getNumberOfParameters() = c.getNumberOfParameters()
3032
select f, "Function overloads a $@ with a forwarding reference parameter.", c, "function"

cpp/autosar/test/rules/A13-3-1/FunctionThatContainsForwardingReferenceAsItsArgumentOverloaded.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
| test.cpp:50:3:50:3 | A | Function overloads a $@ with a forwarding reference parameter. | test.cpp:47:3:47:3 | A | function |
44
| test.cpp:63:8:63:8 | B | Function overloads a $@ with a forwarding reference parameter. | test.cpp:66:3:66:3 | B | function |
55
| test.cpp:63:8:63:8 | B | Function overloads a $@ with a forwarding reference parameter. | test.cpp:66:3:66:3 | B | function |
6+
| test.cpp:71:7:71:7 | C | Function overloads a $@ with a forwarding reference parameter. | test.cpp:74:25:74:25 | C | function |
7+
| test.cpp:71:7:71:7 | C | Function overloads a $@ with a forwarding reference parameter. | test.cpp:74:25:74:25 | C | function |

cpp/autosar/test/rules/A13-3-1/test.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,10 @@ struct B {
6666
B(T &&value) {}
6767
};
6868

69-
int main() {}
69+
int main() {}
70+
71+
class C {
72+
public:
73+
C() {} // COMPLIANT by exception
74+
template <typename T> C(T &&) {}
75+
};

0 commit comments

Comments
 (0)