summaryrefslogtreecommitdiff
path: root/test/SemaTemplate/instantiate-expr-4.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-21 00:00:09 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-21 00:00:09 +0000
commit3433cf7dfda405bf51bba914a338adf645a87e3b (patch)
tree7b2399d8cf04464c4c31ce6c4277e01395ac5325 /test/SemaTemplate/instantiate-expr-4.cpp
parent66b46be52f82addd4edab3a54928e111dfa09de7 (diff)
downloadclang-3433cf7dfda405bf51bba914a338adf645a87e3b.tar.gz
Template instantiation for C++ "new" expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72199 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/instantiate-expr-4.cpp')
-rw-r--r--test/SemaTemplate/instantiate-expr-4.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/test/SemaTemplate/instantiate-expr-4.cpp b/test/SemaTemplate/instantiate-expr-4.cpp
index 8a3f7d858e..a6bafc5b2e 100644
--- a/test/SemaTemplate/instantiate-expr-4.cpp
+++ b/test/SemaTemplate/instantiate-expr-4.cpp
@@ -21,8 +21,8 @@ struct FunctionalCast0 {
template struct FunctionalCast0<5>;
-struct X {
- X(int, int);
+struct X { // expected-note 2 {{candidate function}}
+ X(int, int); // expected-note 2 {{candidate function}}
};
template<int N, int M>
@@ -42,3 +42,44 @@ struct Temporaries0 {
};
template struct Temporaries0<5, 7>;
+
+// ---------------------------------------------------------------------
+// new expressions
+// ---------------------------------------------------------------------
+struct Y { };
+
+template<typename T>
+struct New0 {
+ T* f(bool x) {
+ if (x)
+ return new T; // expected-error{{no matching}}
+ else
+ return new T();
+ }
+};
+
+template struct New0<int>;
+template struct New0<Y>;
+template struct New0<X>; // expected-note{{instantiation}}
+
+template<typename T, typename Arg1>
+struct New1 {
+ T* f(bool x, Arg1 a1) {
+ return new T(a1); // expected-error{{no matching}}
+ }
+};
+
+template struct New1<int, float>;
+template struct New1<Y, Y>;
+template struct New1<X, Y>; // expected-note{{instantiation}}
+
+template<typename T, typename Arg1, typename Arg2>
+struct New2 {
+ T* f(bool x, Arg1 a1, Arg2 a2) {
+ return new T(a1, a2); // expected-error{{no matching}}
+ }
+};
+
+template struct New2<X, int, float>;
+template struct New2<X, int, int*>; // expected-note{{instantiation}}
+// FIXME: template struct New2<int, int, float>;