Skip to content

Commit 33e7f91

Browse files
committed
update diagnostic message
1 parent 0c6e54b commit 33e7f91

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12354,8 +12354,7 @@ def err_preserve_enum_value_not_const: Error<
1235412354
def err_bit_cast_non_trivially_copyable : Error<
1235512355
"__builtin_bit_cast %select{source|destination}0 type must be trivially copyable">;
1235612356
def err_bit_cast_type_size_mismatch : Error<
12357-
"__builtin_bit_cast source type %0 size (%1 %plural{1:byte|:bytes}1) "
12358-
"does not match destination type %2 size (%3 %plural{1:byte|:bytes}3)">;
12357+
"size of '__builtin_bit_cast' source type %0 does not match destination type %1 (%2 vs %3 bytes)">;
1235912358

1236012359
// SYCL-specific diagnostics
1236112360
def warn_sycl_kernel_num_of_template_params : Warning<

clang/lib/Sema/SemaCast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3283,7 +3283,7 @@ void CastOperation::CheckBuiltinBitCast() {
32833283
CharUnits SourceSize = Self.Context.getTypeSizeInChars(SrcType);
32843284
if (DestSize != SourceSize) {
32853285
Self.Diag(OpRange.getBegin(), diag::err_bit_cast_type_size_mismatch)
3286-
<< SrcType << (int)SourceSize.getQuantity() << DestType
3286+
<< SrcType << DestType << (int)SourceSize.getQuantity()
32873287
<< (int)DestSize.getQuantity();
32883288
SrcExpr = ExprError();
32893289
return;

clang/test/AST/ByteCode/builtin-bit-cast.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ typedef bool bool32 __attribute__((ext_vector_type(32)));
496496
typedef bool bool128 __attribute__((ext_vector_type(128)));
497497

498498
static_assert(bit_cast<unsigned char>(bool8{1,0,1,0,1,0,1,0}) == (LITTLE_END ? 0x55 : 0xAA), "");
499-
constexpr bool8 b8 = __builtin_bit_cast(bool8, 0x55); // both-error {{__builtin_bit_cast source type 'int' size (4 bytes) does not match destination type 'bool8' (vector of 8 'bool' values) size (1 byte)}}
499+
constexpr bool8 b8 = __builtin_bit_cast(bool8, 0x55); // both-error {{'__builtin_bit_cast' source type 'int' does not match destination type 'bool8' (vector of 8 'bool' values) (4 vs 1 bytes)}}
500500
#if 0
501501
static_assert(check_round_trip<bool8>(static_cast<unsigned char>(0)), "");
502502
static_assert(check_round_trip<bool8>(static_cast<unsigned char>(1)), "");
@@ -535,5 +535,5 @@ namespace test_complex {
535535
static_assert(TF.A == 1.0f && TF.B == 2.0f);
536536

537537
constexpr double D = __builtin_bit_cast(double, test_float_complex);
538-
constexpr int M = __builtin_bit_cast(int, test_int_complex); // both-error {{__builtin_bit_cast source type 'const _Complex unsigned int' size (8 bytes) does not match destination type 'int' size (4 bytes)}}
538+
constexpr int M = __builtin_bit_cast(int, test_int_complex); // both-error {{size of '__builtin_bit_cast' source type 'const _Complex unsigned int' does not match destination type 'int' (8 vs 4 bytes)}}
539539
}

clang/test/SemaCXX/builtin-bit-cast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void test1() {
2424

2525
void test2() {
2626
constexpr int i = 0;
27-
// expected-error@+1{{__builtin_bit_cast source type 'const int' size (4 bytes) does not match destination type 'char' size (1 byte)}}
27+
// expected-error@+1{{size of '__builtin_bit_cast' source type 'const int' does not match destination type 'char' (4 vs 1 bytes)}}
2828
constexpr char c = __builtin_bit_cast(char, i);
2929
}
3030

clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,5 +525,5 @@ namespace test_complex {
525525
static_assert(TF.A == 1.0f && TF.B == 2.0f);
526526

527527
constexpr double D = __builtin_bit_cast(double, test_float_complex);
528-
constexpr int M = __builtin_bit_cast(int, test_int_complex); // expected-error {{__builtin_bit_cast source type 'const _Complex unsigned int' size (8 bytes) does not match destination type 'int' size (4 bytes)}}
528+
constexpr int M = __builtin_bit_cast(int, test_int_complex); // expected-error {{size of '__builtin_bit_cast' source type 'const _Complex unsigned int' does not match destination type 'int' (8 vs 4 bytes)}}
529529
}

0 commit comments

Comments
 (0)