blob: 2fd9f045693b346adc4f09e250115c3085cd379e [file] [log] [blame]
Douglas Gregord94546a2009-05-20 21:38:11 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3// ---------------------------------------------------------------------
4// C++ Functional Casts
5// ---------------------------------------------------------------------
6template<int N>
7struct ValueInit0 {
8 int f() {
9 return int();
10 }
11};
12
13template struct ValueInit0<5>;
14
15template<int N>
16struct FunctionalCast0 {
17 int f() {
18 return int(N);
19 }
20};
21
22template struct FunctionalCast0<5>;
23
Douglas Gregor3433cf72009-05-21 00:00:09 +000024struct X { // expected-note 2 {{candidate function}}
25 X(int, int); // expected-note 2 {{candidate function}}
Douglas Gregord94546a2009-05-20 21:38:11 +000026};
27
28template<int N, int M>
29struct BuildTemporary0 {
30 X f() {
31 return X(N, M);
32 }
33};
34
35template struct BuildTemporary0<5, 7>;
Douglas Gregore06274d2009-05-20 21:51:01 +000036
37template<int N, int M>
38struct Temporaries0 {
39 void f() {
40 (void)X(N, M);
41 }
42};
43
44template struct Temporaries0<5, 7>;
Douglas Gregor3433cf72009-05-21 00:00:09 +000045
46// ---------------------------------------------------------------------
Douglas Gregord0c02672009-05-21 17:21:12 +000047// new/delete expressions
Douglas Gregor3433cf72009-05-21 00:00:09 +000048// ---------------------------------------------------------------------
49struct Y { };
50
51template<typename T>
52struct New0 {
53 T* f(bool x) {
54 if (x)
55 return new T; // expected-error{{no matching}}
56 else
57 return new T();
58 }
59};
60
61template struct New0<int>;
62template struct New0<Y>;
63template struct New0<X>; // expected-note{{instantiation}}
64
65template<typename T, typename Arg1>
66struct New1 {
67 T* f(bool x, Arg1 a1) {
68 return new T(a1); // expected-error{{no matching}}
69 }
70};
71
72template struct New1<int, float>;
73template struct New1<Y, Y>;
74template struct New1<X, Y>; // expected-note{{instantiation}}
75
76template<typename T, typename Arg1, typename Arg2>
77struct New2 {
78 T* f(bool x, Arg1 a1, Arg2 a2) {
79 return new T(a1, a2); // expected-error{{no matching}}
80 }
81};
82
83template struct New2<X, int, float>;
84template struct New2<X, int, int*>; // expected-note{{instantiation}}
85// FIXME: template struct New2<int, int, float>;
Douglas Gregord0c02672009-05-21 17:21:12 +000086
87template<typename T>
88struct Delete0 {
89 void f(T t) {
90 delete t; // expected-error{{cannot delete}}
91 ::delete [] t;
92 }
93};
94
95template struct Delete0<int*>;
96template struct Delete0<X*>;
97template struct Delete0<int>; // expected-note{{instantiation}}