Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/AST/ByteCode/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,8 +1238,10 @@ static bool checkConstructor(InterpState &S, CodePtr OpPC, const Function *Func,
const Pointer &ThisPtr) {
assert(Func->isConstructor());

const Descriptor *D = ThisPtr.getFieldDesc();
if (Func->getParentDecl()->isInvalidDecl())
return false;

const Descriptor *D = ThisPtr.getFieldDesc();
// FIXME: I think this case is not 100% correct. E.g. a pointer into a
// subobject of a composite array.
if (!D->ElemRecord)
Expand Down
8 changes: 8 additions & 0 deletions clang/test/AST/ByteCode/records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,4 +1738,12 @@ namespace DeadUpcast {
namespace CtorOfInvalidClass {
constexpr struct { Unknown U; } InvalidCtor; // both-error {{unknown type name 'Unknown'}} \
// both-error {{must be initialized by a constant expression}}

#if __cplusplus >= 202002L
template <typename T, auto Q>
concept ReferenceOf = Q;
/// This calls a valid and constexpr copy constructor of InvalidCtor,
/// but should still be rejected.
template<ReferenceOf<InvalidCtor> auto R, typename Rep> int F; // both-error {{non-type template argument is not a constant expression}}
#endif
}
Loading