| 1 |
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s |
| 2 |
|
| 3 |
float test1(int cond, float a, float b) { |
| 4 |
return cond ? a : b; |
| 5 |
} |
| 6 |
|
| 7 |
double test2(int cond, float a, double b) { |
| 8 |
return cond ? a : b; |
| 9 |
} |
| 10 |
|
| 11 |
void f(void); |
| 12 |
|
| 13 |
void test3(void){ |
| 14 |
1 ? f() : (void)0; |
| 15 |
} |
| 16 |
|
| 17 |
void test4(void) { |
| 18 |
int i; short j; |
| 19 |
float* k = 1 ? &i : &j; |
| 20 |
} |
| 21 |
|
| 22 |
void test5(void) { |
| 23 |
const int* cip; |
| 24 |
void* vp; |
| 25 |
cip = 0 ? vp : cip; |
| 26 |
} |
| 27 |
|
| 28 |
void test6(void); |
| 29 |
void test7(int); |
| 30 |
void* test8(void) {return 1 ? test6 : test7;} |
| 31 |
|
| 32 |
|
| 33 |
void _efree(void *ptr); |
| 34 |
void free(void *ptr); |
| 35 |
|
| 36 |
void _php_stream_free3(void) { |
| 37 |
(1 ? free(0) : _efree(0)); |
| 38 |
} |
| 39 |
|
| 40 |
void _php_stream_free4(void) { |
| 41 |
1 ? _efree(0) : free(0); |
| 42 |
} |
| 43 |
|
| 44 |
// PR5526 |
| 45 |
struct test9 { int a; }; |
| 46 |
void* test9spare(void); |
| 47 |
void test9(struct test9 *p) { |
| 48 |
p ? p : test9spare(); |
| 49 |
} |
| 50 |
|
| 51 |
// CHECK: @test10 |
| 52 |
// CHECK: select i1 {{.*}}, i32 4, i32 5 |
| 53 |
int test10(int c) { |
| 54 |
return c ? 4 : 5; |
| 55 |
} |
| 56 |
enum { Gronk = 5 }; |
| 57 |
|
| 58 |
// CHECK: @test11 |
| 59 |
// CHECK: select i1 {{.*}}, i32 4, i32 5 |
| 60 |
int test11(int c) { |
| 61 |
return c ? 4 : Gronk; |
| 62 |
} |
| 63 |
|
| 64 |
// CHECK: @test12 |
| 65 |
// CHECK: select i1 {{.*}}, double 4.0{{.*}}, double 2.0 |
| 66 |
double test12(int c) { |
| 67 |
return c ? 4.0 : 2.0; |
| 68 |
} |
| 69 |
// CHECK: @test13 |
| 70 |
// CHECK: call {{.*}} @f2( |
| 71 |
int f2(void); |
| 72 |
void test13(void) { |
| 73 |
f2() ? (void)0 : (void)0; |
| 74 |
} |