Skip to content

Commit 6696e0c

Browse files
authored
[clang][bytecode] Remove double diagnostic emission (#169658)
We emit this diagnostic from CheckPointerToIntegralCast() already, so remove the emission from CastPointerIntegral().
1 parent fede947 commit 6696e0c

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,15 +2081,15 @@ bool InvalidShuffleVectorIndex(InterpState &S, CodePtr OpPC, uint32_t Index) {
20812081

20822082
bool CheckPointerToIntegralCast(InterpState &S, CodePtr OpPC,
20832083
const Pointer &Ptr, unsigned BitWidth) {
2084+
const SourceInfo &E = S.Current->getSource(OpPC);
2085+
S.CCEDiag(E, diag::note_constexpr_invalid_cast)
2086+
<< 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
2087+
20842088
if (Ptr.isDummy())
20852089
return false;
20862090
if (Ptr.isFunctionPointer())
20872091
return true;
20882092

2089-
const SourceInfo &E = S.Current->getSource(OpPC);
2090-
S.CCEDiag(E, diag::note_constexpr_invalid_cast)
2091-
<< 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
2092-
20932093
if (Ptr.isBlockPointer() && !Ptr.isZero()) {
20942094
// Only allow based lvalue casts if they are lossless.
20952095
if (S.getASTContext().getTargetInfo().getPointerWidth(LangAS::Default) !=

clang/lib/AST/ByteCode/Interp.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,10 +2646,6 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
26462646
bool CastPointerIntegral(InterpState &S, CodePtr OpPC) {
26472647
const Pointer &Ptr = S.Stk.pop<Pointer>();
26482648

2649-
S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_cast)
2650-
<< diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
2651-
<< S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
2652-
26532649
if (!CheckPointerToIntegralCast(S, OpPC, Ptr, T::bitWidth()))
26542650
return Invalid(S, OpPC);
26552651

0 commit comments

Comments
 (0)