summaryrefslogtreecommitdiff
path: root/clang/test/Coverage/c-language-features.inc
blob: 0ff1237b12e8f6efcf2f115a8c1a6150ca533ea4 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
//-*- C -*-

/* This is a 
   multiline comment */

// Intended to exercise all syntactic parts of the C language.

int g0;
int g1, g2;

struct s0;

struct s0 {
  int x;
};

int g3 = 10;

__asm("");

typedef int td0;

td0 g4;

enum e0 {
  ec0
};

static void f0(int x) {
}

inline void f0_0(int x) {
  ;
}

extern void f0_1(int x) {
}

void f1(int, ...);

// Statements.
void f2() {
  for (;;) {
    break;
    continue;
  }

  while (0) {
  }

  do {
  } while (0);

  void *label = &&theif;
  goto *label;

  goto theif;
theif:
  if (0) {
    ;
  } else if (0) {
  } else {
  }

  switch(0) {
  case 0:
  case 1 ... 2:
    break;
  default:
    break;
  }

  asm ("nop");

  return;
}

// Expressions.

#include <stdarg.h>

typedef struct ipair {
  int first, second;
} ipair;

void f4(int a0, int a1, int a2, va_list ap) {
  int t0 = a0 ? a1 : a2;
  float t1 = (float) a0;
  ipair t2 = {1, 2};
  ipair t2a = { .second = 2 };
  int t3 = sizeof(ipair);
  ipair t4;
  t4 = (ipair) {1, 2};
  extern int g(int);
  int t5 = g(a0);
  int t6 = t4.first;
  int t7[10];
  int t8 = t7[a0];
  t8++;
  const char *t9 = __FUNCTION__;
  char t10 = 'x';
  int t11 = __builtin_offsetof(ipair, first);
  int t12 = __builtin_types_compatible_p(ipair, int);  
  int t12_0 = __builtin_classify_type(t0);
  int t12_1 = __builtin_classify_type(t1);
  int t12_2 = __builtin_classify_type(t2);
  // FIXME: Add _Complex and aggregate cases.
  int t13 = va_arg(ap, int);
  va_list t13_0;
  va_copy(t13_0, ap);
  int t14 = __extension__(t13);
  int t15 = +t13;
  unsigned t16 = t14 ^ t15;
  int t17 = t14 % t15;
  int t17_0 = t16 % t16;
  float t18;
  int t19 = t18 ? 0 : 1;
  char *t20; ++t20; --t20;
  float t21; ++t21; --t21;
  double t22; ++t22; --t22;
  long double t23; ++t23; --t23;
  int t24 = !t19;
  int t25 = __real t24;
  int t26 = __imag t24;
  const char *t27 = t9;
  t27 += (unsigned char) 0xFF;
  t27 += (signed char) 0xFF;
  
  struct { char f0[10]; } *t28;
  int t29 = t28 - t28;
  char *t30 = &t28->f0[1];

  struct s1 { int f0; };
  struct s1 t31_a, t31_b;
  int t31_cond;
  int t31 = (t31_cond ? t31_a : t31_b).f0;

  _Complex float t32_a, t32_b;
  int t32_cond;
  int t32 = __real (t32_cond ? t32_a : t32_b);

  struct { int x, y; } t33, *t34, t35[12], t36(int, float);
  float t37, *t38, t39[9], t40(double);
}

// Extended vectors

typedef __attribute__((ext_vector_type(2))) float float2;
typedef __attribute__((ext_vector_type(4))) float float4;

void f5() {
  float4 t0 = (float4) { 0, 1, 2, 3 };
  float4 t1 = t0;
  t0.lo.even = t1.hi.x;

  // irgen doesn't support this yet.
#if 0
  int t2_cond;
  float2 t2 = (t2_cond ? t0 : t1).lo;
#endif
}

void f6() {
  const char *s0 = __func__;
  const char *s1 = __FUNCTION__;
  const char *s2 = __PRETTY_FUNCTION__;
}

// Arg mismatch with passed type.
void f7(x) 
     float x;
{
}

void f8(x) 
     short x;
{
}

// Function which inputs an array
void f9(int x[]) { }

// Object literals.
void f10() {
  struct f10_s0 {
    char iv0[10];
  } x;

  x = (struct f10_s0) { .iv0 = "name" };
}

// Nested structures.
struct s11 {
  struct s11_2 {
    int f0;
  } f0;
  int f1;
};