[clang][bytecode] Diagnose IntegralToPointer casts to non-void (#123619)
But keep evaluating. This is what the current interpreter does as well.
This commit is contained in:
parent
f33e3d422d
commit
e8674af6f4
@ -2693,6 +2693,10 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
|
||||
inline bool GetIntPtr(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
|
||||
const T &IntVal = S.Stk.pop<T>();
|
||||
|
||||
if (Desc)
|
||||
S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_cast)
|
||||
<< 2 << S.getLangOpts().CPlusPlus;
|
||||
|
||||
S.Stk.push<Pointer>(static_cast<uint64_t>(IntVal), Desc);
|
||||
return true;
|
||||
}
|
||||
|
@ -309,8 +309,8 @@ constexpr const int *V81 = &V80;
|
||||
constexpr int *V82 = 0;
|
||||
constexpr int *V83 = V82;
|
||||
constexpr int *V84 = 42;
|
||||
// ref-error@-1 {{constexpr variable 'V84' must be initialized by a constant expression}}
|
||||
// ref-note@-2 {{this conversion is not allowed in a constant expression}}
|
||||
// both-error@-1 {{constexpr variable 'V84' must be initialized by a constant expression}}
|
||||
// both-note@-2 {{this conversion is not allowed in a constant expression}}
|
||||
// both-error@-3 {{constexpr pointer initializer is not null}}
|
||||
constexpr int *V85 = nullptr;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -triple x86_64-linux-gnu %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -triple x86_64-linux-gnu %s -fexperimental-new-constant-interpreter
|
||||
|
||||
int n;
|
||||
constexpr int *p = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user