OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [c1x-uni-string-1.c] - Blame information for rev 753

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test Unicode strings in C1X.  Test valid code.  */
2
/* { dg-do run } */
3
/* { dg-options "-std=c1x -pedantic-errors" } */
4
 
5
/* More thorough tests are in c-c++-common/raw-string-*.c; this test
6
   verifies the particular subset (Unicode but not raw strings) that
7
   is in C1X.  */
8
 
9
typedef __CHAR16_TYPE__ char16_t;
10
typedef __CHAR32_TYPE__ char32_t;
11
typedef __SIZE_TYPE__ size_t;
12
 
13
extern void abort (void);
14
extern void exit (int);
15
extern int memcmp (const void *, const void *, size_t);
16
 
17
#define R "(R)"
18
#define u8R "(u8R)"
19
#define uR "(uR)"
20
#define UR "(UR)"
21
#define LR "(LR)"
22
#define u8 randomu8
23
#define u randomu
24
#define U randomU
25
 
26
const char su8[] = u8"a\u010d";
27
const char su8a[] = "a\xc4\x8d";
28
 
29
const char16_t su16[] = u"\u0567";
30
const char16_t su16a[] = { 0x0567, 0 };
31
 
32
const char32_t su32[] = U"\u0123";
33
const char32_t su32a[] = { 0x0123, 0 };
34
 
35
const char tu[] = R"a";
36
const char tua[] = "(R)a";
37
 
38
const char tu8[] = u8R"b";
39
const char tu8a[] = "(u8R)b";
40
 
41
const char tu16[] = uR"c";
42
const char tu16a[] = "(uR)c";
43
 
44
const char tu32[] = UR"d";
45
const char tu32a[] = "(UR)d";
46
 
47
const char tl[] = LR"e";
48
const char tla[] = "(LR)e";
49
 
50
#define str(x) #x
51
const char ts[] = str(u"a" U"b" u8"c");
52
const char tsa[] = "u\"a\" U\"b\" u8\"c\"";
53
 
54
/* GCC always uses UTF-16 and UTF-32 for char16_t and char32_t.  */
55
#ifndef __STDC_UTF_16__
56
#error "__STDC_UTF_16__ not defined"
57
#endif
58
#ifndef __STDC_UTF_32__
59
#error "__STDC_UTF_32__ not defined"
60
#endif
61
#define xstr(x) str(x)
62
const char tm16[] = xstr(__STDC_UTF_16__);
63
const char tm16a[] = "1";
64
const char tm32[] = xstr(__STDC_UTF_32__);
65
const char tm32a[] = "1";
66
 
67
int
68
main (void)
69
{
70
  if (sizeof (su8) != sizeof (su8a)
71
      || memcmp (su8, su8a, sizeof (su8)) != 0)
72
    abort ();
73
  if (sizeof (su16) != sizeof (su16a)
74
      || memcmp (su16, su16a, sizeof (su16)) != 0)
75
    abort ();
76
  if (sizeof (su32) != sizeof (su32a)
77
      || memcmp (su32, su32a, sizeof (su32)) != 0)
78
    abort ();
79
  if (sizeof (tu) != sizeof (tua)
80
      || memcmp (tu, tua, sizeof (tu)) != 0)
81
    abort ();
82
  if (sizeof (tu8) != sizeof (tu8a)
83
      || memcmp (tu8, tu8a, sizeof (tu8)) != 0)
84
    abort ();
85
  if (sizeof (tu16) != sizeof (tu16a)
86
      || memcmp (tu16, tu16a, sizeof (tu16)) != 0)
87
    abort ();
88
  if (sizeof (tu32) != sizeof (tu32a)
89
      || memcmp (tu32, tu32a, sizeof (tu32)) != 0)
90
    abort ();
91
  if (sizeof (tl) != sizeof (tla)
92
      || memcmp (tl, tla, sizeof (tl)) != 0)
93
    abort ();
94
  if (sizeof (ts) != sizeof (tsa)
95
      || memcmp (ts, tsa, sizeof (ts)) != 0)
96
    abort ();
97
  if (sizeof (tm16) != sizeof (tm16a)
98
      || memcmp (tm16, tm16a, sizeof (tm16)) != 0)
99
    abort ();
100
  if (sizeof (tm32) != sizeof (tm32a)
101
      || memcmp (tm32, tm32a, sizeof (tm32)) != 0)
102
    abort ();
103
  if (u'\u0123' != 0x0123)
104
    abort ();
105
  if (U'\u0456' != 0x0456)
106
    abort ();
107
#undef u8
108
#define u8
109
  if (u8'a' != 'a')
110
    abort ();
111
  exit (0);
112
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.