references.cpp revision 5df0d426026b3820b5f0b13a8d4e60e9373d8d9d
1// RUN: clang-cc -verify -emit-llvm -o %t %s
2
3void t1() {
4  extern int& a;
5  int b = a;
6}
7
8void t2(int& a) {
9  int b = a;
10}
11
12int g;
13int& gr = g;
14void t3() {
15  int b = gr;
16}
17
18// Test reference binding.
19
20struct C {};
21
22void f(const bool&);
23void f(const int&);
24void f(const _Complex int&);
25void f(const C&);
26
27C structfunc();
28
29void test_bool() {
30  bool a = true;
31  f(a);
32
33  f(true);
34}
35
36void test_scalar() {
37  int a = 10;
38  f(a);
39
40  struct { int bitfield : 3; } s = { 3 };
41  f(s.bitfield);
42
43  f(10);
44
45  __attribute((vector_size(16))) typedef int vec4;
46  f((vec4){1,2,3,4}[0]);
47}
48
49void test_complex() {
50  _Complex int a = 10i;
51  f(a);
52
53  f(10i);
54}
55
56void test_aggregate() {
57  C c;
58  f(c);
59
60  f(structfunc());
61}
62
63