Skip to content

Commit 60cdc3d

Browse files
authored
[clang] Make sure EvalInfo pointer isn't null (#155563)
It can be null, when called via CheckICE(). Accidentally introduced via #119366 Fixes #155507
1 parent e557ad6 commit 60cdc3d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7975,8 +7975,9 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
79757975
// so its layout is unspecified. For now, we'll simply treat these cases
79767976
// as unsupported (this should only be possible with OpenCL bool vectors
79777977
// whose element count isn't a multiple of the byte size).
7978-
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
7979-
<< QualType(VTy, 0) << EltSize << NElts << Ctx.getCharWidth();
7978+
if (Info)
7979+
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
7980+
<< QualType(VTy, 0) << EltSize << NElts << Ctx.getCharWidth();
79807981
return false;
79817982
}
79827983

@@ -7985,8 +7986,9 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
79857986
// The layout for x86_fp80 vectors seems to be handled very inconsistently
79867987
// by both clang and LLVM, so for now we won't allow bit_casts involving
79877988
// it in a constexpr context.
7988-
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
7989-
<< EltTy;
7989+
if (Info)
7990+
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
7991+
<< EltTy;
79907992
return false;
79917993
}
79927994
}

clang/test/Sema/constexpr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,10 @@ void ghissue109095() {
391391
_Static_assert(i == c[0]); // expected-error {{static assertion expression is not an integral constant expression}}\
392392
// expected-note {{initializer of 'i' is not a constant expression}}
393393
}
394+
395+
typedef bool __vbool2 __attribute__((ext_vector_type(2)));
396+
typedef short v2int16_t __attribute__((ext_vector_type(2)));
397+
398+
bool issue155507(v2int16_t a, v2int16_t b) {
399+
return __builtin_bit_cast(unsigned char, __builtin_convertvector(a == b, __vbool2)) == 0b11;
400+
}

0 commit comments

Comments
 (0)