blob: 38b4bfa38a6e769b85a160c6acd386fcb3af2112 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
Daniel Dunbar7e0c1952009-11-21 09:17:15 +00002namespace test1 {
3int x;
4template <int& D> class T { };
5// CHECK: void @_ZN5test12f0ENS_1TILZNS_1xEEEE(
6void f0(T<x> a0) {}
7}
8
9namespace test1 {
10// CHECK: void @_ZN5test12f0Ef
11void f0(float) {}
12template<void (&)(float)> struct t1 {};
13// CHECK: void @_ZN5test12f1ENS_2t1ILZNS_2f0EfEEE(
14void f1(t1<f0> a0) {}
15}
16
17namespace test2 {
18// CHECK: void @_ZN5test22f0Ef
19void f0(float) {}
20template<void (*)(float)> struct t1 {};
21// FIXME: Fails because we don't treat as an expression.
22// CHECK-FIXME: void @_ZN5test22f1ENS_2t1IXadL_ZNS_2f0EfEEEE(
23void f1(t1<f0> a0) {}
24}
25
26namespace test3 {
27// CHECK: void @test3_f0
28extern "C" void test3_f0(float) {}
29template<void (&)(float)> struct t1 {};
30// FIXME: Fails because we tack on a namespace.
31// CHECK-FIXME: void @_ZN5test32f1ENS_2t1ILZ8test3_f0EEE(
32void f1(t1<test3_f0> a0) {}
33}
34
35namespace test4 {
36// CHECK: void @test4_f0
37extern "C" void test4_f0(float) {}
38template<void (*)(float)> struct t1 {};
39// FIXME: Fails because we don't treat as an expression.
40// CHECK-FIXME: void @_ZN5test42f1ENS_2t1IXadL_Z8test4_f0EEEE(
41void f1(t1<test4_f0> a0) {}
42}
43
44// CHECK: void @test5_f0
45extern "C" void test5_f0(float) {}
46int main(int) {}
47
48namespace test5 {
49template<void (&)(float)> struct t1 {};
50// CHECK: void @_ZN5test52f1ENS_2t1ILZ8test5_f0EEE(
51void f1(t1<test5_f0> a0) {}
52
53template<int (&)(int)> struct t2 {};
54// CHECK: void @_ZN5test52f2ENS_2t2ILZ4mainEEE
55void f2(t2<main> a0) {}
56}
57
58// FIXME: This fails.
59namespace test6 {
60struct A { void im0(float); };
61// CHECK: void @_ZN5test61A3im0Ef
62void A::im0(float) {}
63template <void(A::*)(float)> class T { };
64// FIXME: Fails because we don't treat as an expression.
65// CHECK-FAIL: void @_ZN5test62f0ENS_1TIXadL_ZNS_1A3im0EfEEEE(
66void f0(T<&A::im0> a0) {}
67}
Douglas Gregor5ed1bc32010-02-28 21:40:32 +000068
69namespace test7 {
70 template<typename T>
71 struct meta {
72 static const unsigned value = sizeof(T);
73 };
74
75 template<unsigned> struct int_c {
76 typedef float type;
77 };
78
79 template<typename T>
80 struct X {
81 template<typename U>
82 X(U*, typename int_c<(meta<T>::value + meta<U>::value)>::type *) { }
83 };
84
85 // CHECK: define void @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsrNS6_IS3_EE5valueEE4typeE
86 template X<int>::X(double*, float*);
87}