references.cpp revision 5df0d426026b3820b5f0b13a8d4e60e9373d8d9d
10d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar// RUN: clang-cc -verify -emit-llvm -o %t %s 20d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 30d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid t1() { 40d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar extern int& a; 50d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar int b = a; 60d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar} 70d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 80d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid t2(int& a) { 90d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar int b = a; 100d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar} 110d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 120d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarint g; 130d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarint& gr = g; 140d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid t3() { 150d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar int b = gr; 160d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar} 170d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 180d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar// Test reference binding. 190d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 200d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarstruct C {}; 210d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 220d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid f(const bool&); 230d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid f(const int&); 240d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid f(const _Complex int&); 250d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid f(const C&); 260d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 270d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish MahendrakarC structfunc(); 280d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 290d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid test_bool() { 300d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar bool a = true; 310d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(a); 320d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 330d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(true); 340d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar} 350d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 360d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid test_scalar() { 370d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar int a = 10; 380d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(a); 390d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 400d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar struct { int bitfield : 3; } s = { 3 }; 410d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(s.bitfield); 420d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 430d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(10); 440d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 450d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar __attribute((vector_size(16))) typedef int vec4; 460d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f((vec4){1,2,3,4}[0]); 470d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar} 480d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 490d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid test_complex() { 500d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar _Complex int a = 10i; 510d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(a); 520d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 536c166a9e18156d364d0704fccbd53a7dc022e97dNaveen Kumar Ponnusamy f(10i); 540d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar} 550d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 560d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakarvoid test_aggregate() { 570d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar C c; 580d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(c); 590d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 600d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar f(structfunc()); 610d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar} 620d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar 630d8951cef4b1a1dbf4ff5ba3e8796cf1d4503098Harish Mahendrakar