1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck %s
3 // Verifying that we do, in fact, select the correct function in the following
6 void foo(int m
) __attribute__((overloadable
, enable_if(m
> 0, "")));
7 void foo(int m
) __attribute__((overloadable
));
9 // CHECK-LABEL: define{{.*}} void @test1
11 // CHECK: store ptr @_Z3fooi
13 // CHECK: store ptr @_Z3fooi
14 void (*p2
)(int) = &foo
;
15 // CHECK: store ptr @_Z3fooi
17 // CHECK: store ptr @_Z3fooi
20 // CHECK: store ptr @_Z3fooi
21 void *vp1
= (void*)&foo
;
22 // CHECK: store ptr @_Z3fooi
23 void *vp2
= (void*)foo
;
24 // CHECK: store ptr @_Z3fooi
26 // CHECK: store ptr @_Z3fooi
30 void bar(int m
) __attribute__((overloadable
, enable_if(m
> 0, "")));
31 void bar(int m
) __attribute__((overloadable
, enable_if(1, "")));
32 // CHECK-LABEL: define{{.*}} void @test2
34 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
36 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
37 void (*p2
)(int) = &bar
;
38 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
40 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
43 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
44 void *vp1
= (void*)&bar
;
45 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
46 void *vp2
= (void*)bar
;
47 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
49 // CHECK: store ptr @_Z3barUa9enable_ifILi1EEi
53 void baz(int m
) __attribute__((overloadable
, enable_if(1, "")));
54 void baz(int m
) __attribute__((overloadable
));
55 // CHECK-LABEL: define{{.*}} void @test3
57 // CHECK: store ptr @_Z3bazUa9enable_ifILi1EEi
59 // CHECK: store ptr @_Z3bazUa9enable_ifILi1EEi
60 void (*p2
)(int) = &baz
;
61 // CHECK: store ptr @_Z3bazUa9enable_ifILi1EEi
63 // CHECK: store ptr @_Z3bazUa9enable_ifILi1EEi
68 enum { TRUEFACTS
= 1 };
69 void qux(int m
) __attribute__((overloadable
, enable_if(1, ""),
70 enable_if(TRUEFACTS
, "")));
71 void qux(int m
) __attribute__((overloadable
, enable_if(1, "")));
72 // CHECK-LABEL: define{{.*}} void @test4
74 // CHECK: store ptr @_Z3quxUa9enable_ifILi1ELi1EEi
76 // CHECK: store ptr @_Z3quxUa9enable_ifILi1ELi1EEi
77 void (*p2
)(int) = &qux
;
78 // CHECK: store ptr @_Z3quxUa9enable_ifILi1ELi1EEi
80 // CHECK: store ptr @_Z3quxUa9enable_ifILi1ELi1EEi
84 // There was a bug where, when enable_if was present, overload resolution
85 // wouldn't pay attention to lower-priority attributes.
86 // (N.B. `foo` with pass_object_size should always be preferred)
87 // CHECK-LABEL: define{{.*}} void @test5
89 int foo(char *i
) __attribute__((enable_if(1, ""), overloadable
));
90 int foo(char *i
__attribute__((pass_object_size(0))))
91 __attribute__((enable_if(1, ""), overloadable
));
93 // CHECK: call i32 @_Z3fooUa9enable_ifILi1EEPcU17pass_object_size0