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
10 changes: 6 additions & 4 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7975,8 +7975,9 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
// so its layout is unspecified. For now, we'll simply treat these cases
// as unsupported (this should only be possible with OpenCL bool vectors
// whose element count isn't a multiple of the byte size).
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
<< QualType(VTy, 0) << EltSize << NElts << Ctx.getCharWidth();
if (Info)
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
<< QualType(VTy, 0) << EltSize << NElts << Ctx.getCharWidth();
return false;
}

Expand All @@ -7985,8 +7986,9 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
// The layout for x86_fp80 vectors seems to be handled very inconsistently
// by both clang and LLVM, so for now we won't allow bit_casts involving
// it in a constexpr context.
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
<< EltTy;
if (Info)
Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
<< EltTy;
return false;
}
}
Expand Down
7 changes: 7 additions & 0 deletions clang/test/Sema/constexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,10 @@ void ghissue109095() {
_Static_assert(i == c[0]); // expected-error {{static assertion expression is not an integral constant expression}}\
// expected-note {{initializer of 'i' is not a constant expression}}
}

typedef bool __vbool2 __attribute__((ext_vector_type(2)));
typedef short v2int16_t __attribute__((ext_vector_type(2)));

bool issue155507(v2int16_t a, v2int16_t b) {
return __builtin_bit_cast(unsigned char, __builtin_convertvector(a == b, __vbool2)) == 0b11;
}