brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · afad7c7 Raw
97 lines · c
1// RUN: %clang_cc1 -triple %itanium_abi_triple -Wno-incompatible-function-pointer-types -emit-llvm %s -o - | FileCheck %s2// CHECK: _Z1fPA10_1X3// CHECK: _Z1fPFvvE4 5int __attribute__((overloadable)) f(int x) { return x; }6float __attribute__((overloadable)) f(float x) { return x; }7double __attribute__((overloadable)) f(double x) { return x; }8double _Complex __attribute__((overloadable)) f(double _Complex x) { return x; }9typedef short v4hi __attribute__ ((__vector_size__ (8)));10v4hi __attribute__((overloadable)) f(v4hi x) { return x; }11 12struct X { };13void  __attribute__((overloadable)) f(struct X (*ptr)[10]) { }14 15void __attribute__((overloadable)) f(int x, int y, ...) { }16 17void __attribute__((overloadable)) f(void (*x)(void)) {}18 19int main(void) {20  int iv = 17;21  float fv = 3.0f;22  double dv = 4.0;23  double _Complex cdv;24  v4hi vv;25 26  iv = f(iv);27  fv = f(fv);28  dv = f(dv);29  cdv = f(cdv);30  vv = f(vv);31}32 33// Ensuring that we pick the correct function for taking the address of an34// overload when conversions are involved.35 36void addrof_many(int *a) __attribute__((overloadable, enable_if(0, "")));37void addrof_many(void *a) __attribute__((overloadable));38void addrof_many(char *a) __attribute__((overloadable));39 40void addrof_single(int *a) __attribute__((overloadable, enable_if(0, "")));41void addrof_single(char *a) __attribute__((overloadable, enable_if(0, "")));42void addrof_single(char *a) __attribute__((overloadable));43 44// CHECK-LABEL: define {{(dso_local )?}}void @foo45void foo(void) {46  // CHECK: store ptr @_Z11addrof_manyPc47  void (*p1)(char *) = &addrof_many;48  // CHECK: store ptr @_Z11addrof_manyPv49  void (*p2)(void *) = &addrof_many;50  // CHECK: ptr @_Z11addrof_manyPc51  void *vp1 = (void (*)(char *)) & addrof_many;52  // CHECK: ptr @_Z11addrof_manyPv53  void *vp2 = (void (*)(void *)) & addrof_many;54 55  // CHECK: store ptr @_Z13addrof_singlePc56  void (*p3)(char *) = &addrof_single;57  // CHECK: @_Z13addrof_singlePc58  void (*p4)(int *) = &addrof_single;59  // CHECK: @_Z13addrof_singlePc60  void *vp3 = &addrof_single;61}62 63 64void ovl_bar(char *) __attribute__((overloadable));65void ovl_bar(int) __attribute__((overloadable));66 67// CHECK-LABEL: define {{(dso_local )?}}void @bar68void bar(void) {69  char charbuf[1];70  unsigned char ucharbuf[1];71 72  // CHECK: call void @_Z7ovl_barPc73  ovl_bar(charbuf);74  // CHECK: call void @_Z7ovl_barPc75  ovl_bar(ucharbuf);76}77 78void ovl_baz(int *, int) __attribute__((overloadable));79void ovl_baz(unsigned int *, unsigned int) __attribute__((overloadable));80void ovl_baz2(int, int *) __attribute__((overloadable));81void ovl_baz2(unsigned int, unsigned int *) __attribute__((overloadable));82// CHECK-LABEL: define {{(dso_local )?}}void @baz83void baz(void) {84  unsigned int j;85  // Initial rules for incompatible pointer conversions made this overload86  // ambiguous.87  // CHECK: call void @_Z7ovl_bazPjj88  ovl_baz(&j, 0);89  // CHECK: call void @_Z7ovl_bazPjj90  ovl_baz(&j, 0u);91 92  // CHECK: call void @_Z8ovl_baz2jPj93  ovl_baz2(0, &j);94  // CHECK: call void @_Z8ovl_baz2jPj95  ovl_baz2(0u, &j);96}97