1 // Check the various ways in which the three classes of values 2 // (scalar, complex, aggregate) interact with parameter passing 3 // (function entry, function return, call argument, call result). 4 // 5 // We also check _Bool and empty structures, as these can have annoying 6 // corner cases. 7 8 // RUN: clang-cc %s -triple i386-unknown-unknown -O3 -emit-llvm -o %t && 9 // RUN: not grep '@g0' %t && 10 11 // RUN: clang-cc %s -triple x86_64-unknown-unknown -O3 -emit-llvm -o %t && 12 // RUN: not grep '@g0' %t && 13 14 // RUN: clang-cc %s -triple ppc-unknown-unknown -O3 -emit-llvm -o %t && 15 // RUN: not grep '@g0' %t && 16 // RUN: true 17 18 typedef _Bool BoolTy; 19 typedef int ScalarTy; 20 typedef _Complex int ComplexTy; 21 typedef struct { int a, b, c; } AggrTy; 22 typedef struct { int a[0]; } EmptyTy; 23 24 static int result; 25 26 static BoolTy bool_id(BoolTy a) { return a; } 27 static AggrTy aggr_id(AggrTy a) { return a; } 28 static EmptyTy empty_id(EmptyTy a) { return a; } 29 static ScalarTy scalar_id(ScalarTy a) { return a; } 30 static ComplexTy complex_id(ComplexTy a) { return a; } 31 32 static void bool_mul(BoolTy a) { result *= a; } 33 34 static void aggr_mul(AggrTy a) { result *= a.a * a.b * a.c; } 35 36 static void empty_mul(EmptyTy a) { result *= 53; } 37 38 static void scalar_mul(ScalarTy a) { result *= a; } 39 40 static void complex_mul(ComplexTy a) { result *= __real a * __imag a; } 41 42 extern void g0(void); 43 44 void f0(void) { 45 result = 1; 46 47 bool_mul(bool_id(1)); 48 aggr_mul(aggr_id((AggrTy) { 2, 3, 5})); 49 empty_mul(empty_id((EmptyTy) {})); 50 scalar_mul(scalar_id(7)); 51 complex_mul(complex_id(11 + 13i)); 52 53 // This call should be eliminated. 54 if (result != 2 * 3 * 5 * 7 * 11 * 13 * 53) 55 g0(); 56 } 57 58