references.cpp revision 482656833a71b63f67f3e93ee8c2d45b3d351ca8
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 aggregate_return(); 28 29bool& bool_reference_return(); 30int& int_reference_return(); 31_Complex int& complex_int_reference_return(); 32 33void test_bool() { 34 bool a = true; 35 f(a); 36 37 f(true); 38 39 bool_reference_return() = true; 40} 41 42void test_scalar() { 43 int a = 10; 44 f(a); 45 46 struct { int bitfield : 3; } s = { 3 }; 47 f(s.bitfield); 48 49 f(10); 50 51 __attribute((vector_size(16))) typedef int vec4; 52 f((vec4){1,2,3,4}[0]); 53 54 int_reference_return() = 10; 55} 56 57void test_complex() { 58 _Complex int a = 10i; 59 f(a); 60 61 f(10i); 62 63 complex_int_reference_return() = 10i; 64} 65 66void test_aggregate() { 67 C c; 68 f(c); 69 70 f(aggregate_return()); 71} 72 73