Skip to content

Commit

Permalink
Fix define_class used with local classes.
Browse files Browse the repository at this point in the history
Closes issue #12.
  • Loading branch information
katzdm committed Mar 17, 2024
1 parent 1cefb01 commit 9e18007
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/Sema/Metafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,7 @@ bool define_class(APValue &Result, Sema &S, EvalFn Evaluator, QualType ResultTy,
ParsedAttributesView::none());

S.ActOnTagFinishDefinition(&ClsScope, Tag, Args[0]->getSourceRange());
S.ActOnPopScope(Range.getEnd(), &ClsScope);

RestoreDC();
return SetAndSucceed(Result, makeReflection(ToComplete));
Expand Down
17 changes: 17 additions & 0 deletions libcxx/test/std/experimental/reflection/define-class.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ static_assert(nonstatic_data_members_of(^S).size() == 2);
S s;
} // namespace completion_of_dependent_type

// =========================
// completion_of_local_class
// =========================

namespace completion_of_local_class {
consteval int fn() {
struct S;
static_assert(is_type(define_class(^S, {
data_member_spec(^int, {.name="member"})
})));

S s = {13};
return s.member;
}
static_assert(fn() == 13);
} // namespace completion_of_local_class

// ==================
// static_data_member
// ==================
Expand Down

0 comments on commit 9e18007

Please sign in to comment.