Skip to content

Commit e23b362

Browse files
committed
Change and add test case for diagnostic when doing a C-style bitcast on vectors of x86_fp80
1 parent 38647e8 commit e23b362

File tree

2 files changed

+39
-21
lines changed

2 files changed

+39
-21
lines changed

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def note_constexpr_memcpy_unsupported : Note<
317317
"source is not a contiguous array of at least %4 elements of type %3|"
318318
"destination is not a contiguous array of at least %4 elements of type %3}2">;
319319
def note_constexpr_bit_cast_unsupported_type : Note<
320-
"constexpr bit_cast involving type %0 is not yet supported">;
320+
"constexpr bit cast involving type %0 is not yet supported">;
321321
def note_constexpr_bit_cast_unsupported_bitfield : Note<
322322
"constexpr bit_cast involving bit-field is not yet supported">;
323323
def note_constexpr_bit_cast_invalid_type : Note<

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

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,47 @@ struct fp80x2_s {
2020
}
2121
};
2222

23-
constexpr static fp80x2_v test_vec_fp80 = { 1, 2 };
24-
constexpr static fp80x2_s test_str_fp80 = { { 0, 0, 0, 0, 0, 0, 0, -128, -1, 63, 0, 0, 0, 0, 0, 0, 0, -128, 0, 64 }, {} };
23+
namespace builtin_bit_cast {
24+
constexpr static fp80x2_v test_vec_fp80 = { 1, 2 };
25+
constexpr static fp80x2_s test_str_fp80 = { { 0, 0, 0, 0, 0, 0, 0, -128, -1, 63, 0, 0, 0, 0, 0, 0, 0, -128, 0, 64 }, {} };
2526

26-
// expected-error@+2 {{static assertion expression is not an integral constant expression}}
27-
// expected-note@+1 {{constexpr bit_cast involving type 'long double' is not yet supported}}
28-
static_assert(__builtin_bit_cast(fp80x2_s, test_vec_fp80) == test_str_fp80, "");
27+
// expected-error@+2 {{static assertion expression is not an integral constant expression}}
28+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
29+
static_assert(__builtin_bit_cast(fp80x2_s, test_vec_fp80) == test_str_fp80, "");
2930

30-
// expected-error@+2 {{static assertion expression is not an integral constant expression}}
31-
// expected-note@+1 {{constexpr bit_cast involving type 'long double' is not yet supported}}
32-
static_assert(__builtin_bit_cast(fp80x2_s, __builtin_bit_cast(fp80x2_v, test_str_fp80)) == test_str_fp80, "");
31+
// expected-error@+2 {{static assertion expression is not an integral constant expression}}
32+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
33+
static_assert(__builtin_bit_cast(fp80x2_s, __builtin_bit_cast(fp80x2_v, test_str_fp80)) == test_str_fp80, "");
3334

34-
// expected-error@+2 {{constexpr variable 'bad_str_fp80_0' must be initialized by a constant expression}}
35-
// expected-note@+1 {{constexpr bit_cast involving type 'long double' is not yet supported}}
36-
constexpr static char bad_str_fp80_0 = __builtin_bit_cast(fp80x2_s, test_vec_fp80)._pad[0];
35+
// expected-error@+2 {{constexpr variable 'bad_str_fp80_0' must be initialized by a constant expression}}
36+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
37+
constexpr static char bad_str_fp80_0 = __builtin_bit_cast(fp80x2_s, test_vec_fp80)._pad[0];
3738

38-
// expected-error@+2 {{constexpr variable 'bad_str_fp80_1' must be initialized by a constant expression}}
39-
// expected-note@+1 {{constexpr bit_cast involving type 'long double' is not yet supported}}
40-
constexpr static char bad_str_fp80_1 = __builtin_bit_cast(fp80x2_s, test_vec_fp80)._pad[1];
39+
// expected-error@+2 {{constexpr variable 'bad_str_fp80_1' must be initialized by a constant expression}}
40+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
41+
constexpr static char bad_str_fp80_1 = __builtin_bit_cast(fp80x2_s, test_vec_fp80)._pad[1];
4142

42-
// expected-error@+2 {{constexpr variable 'bad_str_fp80_11' must be initialized by a constant expression}}
43-
// expected-note@+1 {{constexpr bit_cast involving type 'long double' is not yet supported}}
44-
constexpr static char bad_str_fp80_11 = __builtin_bit_cast(fp80x2_s, test_vec_fp80)._pad[11];
43+
// expected-error@+2 {{constexpr variable 'bad_str_fp80_11' must be initialized by a constant expression}}
44+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
45+
constexpr static char bad_str_fp80_11 = __builtin_bit_cast(fp80x2_s, test_vec_fp80)._pad[11];
4546

46-
// expected-error@+2 {{constexpr variable 'struct2v' must be initialized by a constant expression}}
47-
// expected-note@+1 {{constexpr bit_cast involving type 'long double' is not yet supported}}
48-
constexpr static fp80x2_v struct2v = __builtin_bit_cast(fp80x2_v, test_str_fp80);
47+
// expected-error@+2 {{constexpr variable 'struct2v' must be initialized by a constant expression}}
48+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
49+
constexpr static fp80x2_v struct2v = __builtin_bit_cast(fp80x2_v, test_str_fp80);
50+
}
51+
52+
namespace c_cast {
53+
typedef short v12i16 __attribute((vector_size(24)));
54+
typedef long double v2f80 __attribute((vector_size(24)));
55+
56+
// FIXME: re-enable the corresponding test cases in CodeGen/const-init.c when
57+
// constexpr bitcast with x86_fp80 is supported
58+
59+
// expected-error@+2 {{constexpr variable 'b' must be initialized by a constant expression}}
60+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
61+
constexpr static v12i16 b = (v12i16)(v2f80){1,2};
62+
63+
// expected-error@+2 {{constexpr variable 'c' must be initialized by a constant expression}}
64+
// expected-note@+1 {{constexpr bit cast involving type 'long double' is not yet supported}}
65+
constexpr static v2f80 c = (v2f80)(v12i16){0,0,0,-32768,16383,0,0,0,0,-32768,16384,0};
66+
}

0 commit comments

Comments
 (0)