Skip to content

Address False Positives for Autosar A13-5-2 #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 8, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `A13-5-2` - address a false positive where lambda expressions with empty captures were being flagged as having a non-compliant conversion operator.
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ class ExplicitConversionOperator extends ConversionOperator {
from ConversionOperator op
where
not isExcluded(op, OperatorsPackage::userDefinedConversionOperatorsNotDefinedExplicitQuery()) and
not op instanceof ExplicitConversionOperator
not op instanceof ExplicitConversionOperator and
not op.isCompilerGenerated()
select op, "User-defined conversion operator is not explicit."
13 changes: 12 additions & 1 deletion cpp/autosar/test/rules/A13-5-2/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ class A {
operator int() const { return d; } // NON_COMPLIANT
private:
float d;
};
};

void test_compiler_generated() {
int x = 0;

auto capture = [x]() -> int { return x; };

auto no_capture = []() -> int {
int x = 1;
return x;
};
}