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
3 changes: 1 addition & 2 deletions clang/lib/AST/ByteCode/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,7 @@ bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
if (AK == AK_Read || AK == AK_Increment || AK == AK_Decrement)
return diagnoseUnknownDecl(S, OpPC, D);

assert(AK == AK_Assign);
if (S.getLangOpts().CPlusPlus14) {
if (AK == AK_Destroy || S.getLangOpts().CPlusPlus14) {
const SourceInfo &E = S.Current->getSource(OpPC);
S.FFDiag(E, diag::note_constexpr_modify_global);
}
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,8 @@ bool GetLocal(InterpState &S, CodePtr OpPC, uint32_t I) {

static inline bool Kill(InterpState &S, CodePtr OpPC) {
const auto &Ptr = S.Stk.pop<Pointer>();
if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
return false;
Ptr.endLifetime();
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions clang/test/AST/ByteCode/lifetimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,10 @@ namespace PseudoDtor {
}
return true;
}

int k;
struct T {
int n : (k.~I(), 1); // both-error {{constant expression}} \
// both-note {{visible outside that expression}}
};
}
Loading