Skip to content

Commit d61864f

Browse files
committed
[clang][Interp] Don't create Records for incomplete decls
We would previously create the Record instance with 0 fields, which is incorrect. We later see it again with 1 field. Fixes llvm#82203
1 parent fcf3ca9 commit d61864f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/AST/Interp/Program.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
232232
if (!RD)
233233
return nullptr;
234234

235+
if (!RD->isCompleteDefinition())
236+
return nullptr;
237+
235238
// Deduplicate records.
236239
if (auto It = Records.find(RD); It != Records.end())
237240
return It->second;

clang/test/AST/Interp/lambda.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,16 @@ namespace GH62611 {
222222
return 0;
223223
}
224224
}
225+
226+
namespace LambdaToAPValue {
227+
void wrapper() {
228+
constexpr auto f = []() constexpr {
229+
return 0;
230+
};
231+
232+
constexpr auto g = [f]() constexpr {
233+
return f();
234+
};
235+
static_assert(g() == f(), "");
236+
}
237+
}

0 commit comments

Comments
 (0)