Skip to content
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;
};
}