Skip to content

Commit

Permalink
[clang][Interp] Don't create Records for incomplete decls
Browse files Browse the repository at this point in the history
We would previously create the Record instance with 0 fields,
which is incorrect. We later see it again with 1 field.

Fixes #82203
  • Loading branch information
tbaederr committed Feb 19, 2024
1 parent fcf3ca9 commit d61864f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/AST/Interp/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
if (!RD)
return nullptr;

if (!RD->isCompleteDefinition())
return nullptr;

// Deduplicate records.
if (auto It = Records.find(RD); It != Records.end())
return It->second;
Expand Down
13 changes: 13 additions & 0 deletions clang/test/AST/Interp/lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,16 @@ namespace GH62611 {
return 0;
}
}

namespace LambdaToAPValue {
void wrapper() {
constexpr auto f = []() constexpr {
return 0;
};

constexpr auto g = [f]() constexpr {
return f();
};
static_assert(g() == f(), "");
}
}

0 comments on commit d61864f

Please sign in to comment.