diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-05-15 23:57:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-05-15 23:57:33 +0000 |
commit | dbb26db1d426fb6caaaf1b4fa47b46d1947c12c9 (patch) | |
tree | 7f9391cb5b808d440b7acd28628112a616cae5fc /test/SemaTemplate/instantiate-function-1.cpp | |
parent | c13b7ca5f5c81d0a526bda179d3cd700882e713e (diff) |
Template instantiation for switch statements
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71916 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/instantiate-function-1.cpp')
-rw-r--r-- | test/SemaTemplate/instantiate-function-1.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/SemaTemplate/instantiate-function-1.cpp b/test/SemaTemplate/instantiate-function-1.cpp index 1dfe9e2da6..abd0d1c0fb 100644 --- a/test/SemaTemplate/instantiate-function-1.cpp +++ b/test/SemaTemplate/instantiate-function-1.cpp @@ -140,3 +140,33 @@ template<typename T> struct Member0 { this.f; // expected-error{{member reference base type 'struct Member0 *const' is not a structure or union}} } }; + +template<typename T, typename U> struct Switch0 { + U f(T value, U v0, U v1, U v2) { + switch (value) { + case 0: return v0; + + case 1: return v1; + + case 2: // fall through + + default: + return v2; + } + } +}; + +template struct Switch0<int, float>; + +template<typename T, int I1, int I2> struct Switch1 { + T f(T x, T y, T z) { + switch (x) { + case I1: return y; // expected-note{{previous}} + case I2: return z; // expected-error{{duplicate}} + default: return x; + } + } +}; + +template struct Switch1<int, 1, 2>; +template struct Switch1<int, 2, 2>; // expected-note{{instantiation}} |