]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/init-string-2.c
replace ISL with isl
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / init-string-2.c
CommitLineData
197463ae
JM
1/* Character arrays but not arrays of compatible enum type may be
2 initialized by narrow string literals. Arrays of type compatible
3 with wchar_t, including compatible enums, may be initialized by
4 wide string literals. Use -fshort-enums -fshort-wchar so the
5 relevant circumstances can be obtained portably; may still fail if
6 char, short and int do not all have distinct precisions. */
7/* { dg-do compile } */
a239aa95 8/* { dg-require-effective-target int32plus } */
197463ae
JM
9/* { dg-options "-std=c99 -pedantic-errors -fshort-enums -fshort-wchar" } */
10
11#include <limits.h>
12#include <stddef.h>
13
14typedef enum { schar_min = SCHAR_MIN, schar_max = SCHAR_MAX } schar;
15typedef enum { uchar_max = UCHAR_MAX } uchar;
16typedef enum { shrt_min = SHRT_MIN, shrt_max = SHRT_MAX } sshrt;
17typedef enum { ushrt_max = USHRT_MAX } ushrt;
18
19char a0[] = "foo";
20const signed char a2[4] = "foo";
21volatile unsigned char a3[3] = "foo";
22wchar_t a4[] = L"foo";
23const wchar_t a5[3] = L"foo";
24volatile ushrt a6[] = L"foo";
25
26schar a7[] = "foo"; /* { dg-error "string constant" "a7" } */
27uchar a8[] = "foo"; /* { dg-error "string constant" "a8" } */
28const schar a9[] = "foo"; /* { dg-error "string constant" "a9" } */
29short a10[] = L"foo"; /* { dg-error "string constant" "a10" } */
30const sshrt a11[] = L"foo"; /* { dg-error "string constant" "a11" } */
31char a12[] = L"foo"; /* { dg-error "from wide string" "a12" } */
32wchar_t a13[] = "foo"; /* { dg-error "non-wide string" "a13" } */
33
34char b0[] = { "foo" };
35const signed char b2[4] = { "foo" };
36volatile unsigned char b3[3] = { "foo" };
37wchar_t b4[] = { L"foo" };
38const wchar_t b5[3] = { L"foo" };
39volatile ushrt b6[] = { L"foo" };
40
41schar b7[] = { "foo" }; /* { dg-error "string constant" "b7" } */
42uchar b8[] = { "foo" }; /* { dg-error "string constant" "b8" } */
43const schar b9[] = { "foo" }; /* { dg-error "string constant" "b9" } */
44short b10[] = { L"foo" }; /* { dg-error "string constant" "b10" } */
45const sshrt b11[] = { L"foo" }; /* { dg-error "string constant" "b11" } */
46char b12[] = { L"foo" }; /* { dg-error "from wide string" "b12" } */
47wchar_t b13[] = { "foo" }; /* { dg-error "non-wide string" "b13" } */
48
49struct s { signed char a[10]; int b; ushrt c[10]; };
50
51struct s c = { "foo", 0, L"bar" };
52struct s d = { .c = L"bar", .a = "foo" };
53
54ushrt *e = (ushrt [7]){ L"bar" };
55
56wchar_t f[5][5] = { L"foo", L"bar" };
57ushrt g[5][5] = { L"foo", L"bar" };