Skip to content

Commit a7002fb

Browse files
committed
[clang][dataflow] Add test repro for a crash
An issue with looking up the "this" when a default init of field2 refers to field1.
1 parent 6e7da07 commit a7002fb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,6 +3863,25 @@ TEST_P(UncheckedOptionalAccessTest, ConstBoolAccessorWithModInBetween) {
38633863
)cc");
38643864
}
38653865

3866+
TEST_P(UncheckedOptionalAccessTest, ConstructorOtherStructField) {
3867+
// Repro for a crash.
3868+
ExpectDiagnosticsFor(R"cc(
3869+
#include "unchecked_optional_access_test.h"
3870+
struct NonTrivDtor {
3871+
NonTrivDtor(int x);
3872+
~NonTrivDtor() {}
3873+
};
3874+
struct Other {
3875+
$ns::$optional<int> x = $ns::nullopt;
3876+
NonTrivDtor y = x.has_value() ? NonTrivDtor(*x) : NonTrivDtor(-1);
3877+
};
3878+
struct target {
3879+
target() { Other{}; }
3880+
};
3881+
)cc");
3882+
}
3883+
3884+
38663885
// FIXME: Add support for:
38673886
// - constructors (copy, move)
38683887
// - assignment operators (default, copy, move)

0 commit comments

Comments
 (0)