Mercurial > hg > CbC > CbC_llvm
comparison clang/test/CodeGen/enable_if.c @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 1d019706d866 |
children | c4bab56944e8 |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
4 // cases. | 4 // cases. |
5 | 5 |
6 void foo(int m) __attribute__((overloadable, enable_if(m > 0, ""))); | 6 void foo(int m) __attribute__((overloadable, enable_if(m > 0, ""))); |
7 void foo(int m) __attribute__((overloadable)); | 7 void foo(int m) __attribute__((overloadable)); |
8 | 8 |
9 // CHECK-LABEL: define void @test1 | 9 // CHECK-LABEL: define{{.*}} void @test1 |
10 void test1() { | 10 void test1() { |
11 // CHECK: store void (i32)* @_Z3fooi | 11 // CHECK: store void (i32)* @_Z3fooi |
12 void (*p)(int) = foo; | 12 void (*p)(int) = foo; |
13 // CHECK: store void (i32)* @_Z3fooi | 13 // CHECK: store void (i32)* @_Z3fooi |
14 void (*p2)(int) = &foo; | 14 void (*p2)(int) = &foo; |
27 vp1 = (void*)foo; | 27 vp1 = (void*)foo; |
28 } | 28 } |
29 | 29 |
30 void bar(int m) __attribute__((overloadable, enable_if(m > 0, ""))); | 30 void bar(int m) __attribute__((overloadable, enable_if(m > 0, ""))); |
31 void bar(int m) __attribute__((overloadable, enable_if(1, ""))); | 31 void bar(int m) __attribute__((overloadable, enable_if(1, ""))); |
32 // CHECK-LABEL: define void @test2 | 32 // CHECK-LABEL: define{{.*}} void @test2 |
33 void test2() { | 33 void test2() { |
34 // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi | 34 // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi |
35 void (*p)(int) = bar; | 35 void (*p)(int) = bar; |
36 // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi | 36 // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi |
37 void (*p2)(int) = &bar; | 37 void (*p2)(int) = &bar; |
38 // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi | 38 // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi |
39 p = bar; | 39 p = bar; |
40 // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi | 40 // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi |
41 p = &bar; | 41 p = &bar; |
42 | 42 |
43 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) | 43 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) |
44 void *vp1 = (void*)&bar; | 44 void *vp1 = (void*)&bar; |
45 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) | 45 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) |
46 void *vp2 = (void*)bar; | 46 void *vp2 = (void*)bar; |
47 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) | 47 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) |
48 vp1 = (void*)&bar; | 48 vp1 = (void*)&bar; |
49 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) | 49 // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) |
50 vp1 = (void*)bar; | 50 vp1 = (void*)bar; |
51 } | 51 } |
52 | 52 |
53 void baz(int m) __attribute__((overloadable, enable_if(1, ""))); | 53 void baz(int m) __attribute__((overloadable, enable_if(1, ""))); |
54 void baz(int m) __attribute__((overloadable)); | 54 void baz(int m) __attribute__((overloadable)); |
55 // CHECK-LABEL: define void @test3 | 55 // CHECK-LABEL: define{{.*}} void @test3 |
56 void test3() { | 56 void test3() { |
57 // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi | 57 // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi |
58 void (*p)(int) = baz; | 58 void (*p)(int) = baz; |
59 // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi | 59 // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi |
60 void (*p2)(int) = &baz; | 60 void (*p2)(int) = &baz; |
61 // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi | 61 // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi |
62 p = baz; | 62 p = baz; |
63 // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi | 63 // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi |
64 p = &baz; | 64 p = &baz; |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 const int TRUEFACTS = 1; | 68 enum { TRUEFACTS = 1 }; |
69 void qux(int m) __attribute__((overloadable, enable_if(1, ""), | 69 void qux(int m) __attribute__((overloadable, enable_if(1, ""), |
70 enable_if(TRUEFACTS, ""))); | 70 enable_if(TRUEFACTS, ""))); |
71 void qux(int m) __attribute__((overloadable, enable_if(1, ""))); | 71 void qux(int m) __attribute__((overloadable, enable_if(1, ""))); |
72 // CHECK-LABEL: define void @test4 | 72 // CHECK-LABEL: define{{.*}} void @test4 |
73 void test4() { | 73 void test4() { |
74 // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXL_Z9TRUEFACTSEEEi | 74 // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi |
75 void (*p)(int) = qux; | 75 void (*p)(int) = qux; |
76 // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXL_Z9TRUEFACTSEEEi | 76 // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi |
77 void (*p2)(int) = &qux; | 77 void (*p2)(int) = &qux; |
78 // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXL_Z9TRUEFACTSEEEi | 78 // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi |
79 p = qux; | 79 p = qux; |
80 // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXL_Z9TRUEFACTSEEEi | 80 // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi |
81 p = &qux; | 81 p = &qux; |
82 } | 82 } |
83 | 83 |
84 // There was a bug where, when enable_if was present, overload resolution | 84 // There was a bug where, when enable_if was present, overload resolution |
85 // wouldn't pay attention to lower-priority attributes. | 85 // wouldn't pay attention to lower-priority attributes. |
86 // (N.B. `foo` with pass_object_size should always be preferred) | 86 // (N.B. `foo` with pass_object_size should always be preferred) |
87 // CHECK-LABEL: define void @test5 | 87 // CHECK-LABEL: define{{.*}} void @test5 |
88 void test5() { | 88 void test5() { |
89 int foo(char *i) __attribute__((enable_if(1, ""), overloadable)); | 89 int foo(char *i) __attribute__((enable_if(1, ""), overloadable)); |
90 int foo(char *i __attribute__((pass_object_size(0)))) | 90 int foo(char *i __attribute__((pass_object_size(0)))) |
91 __attribute__((enable_if(1, ""), overloadable)); | 91 __attribute__((enable_if(1, ""), overloadable)); |
92 | 92 |
93 // CHECK: call i32 @_Z3fooUa9enable_ifIXLi1EEEPcU17pass_object_size0 | 93 // CHECK: call i32 @_Z3fooUa9enable_ifILi1EEPcU17pass_object_size0 |
94 foo((void*)0); | 94 foo((void*)0); |
95 } | 95 } |