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 | 2a2d00f041a2eca6453443fb4853816b63c12dcd (patch) | |
tree | 1e4b83256a58e534ede8a02b3d2dfe7e54436355 /clang/test/SemaTemplate/instantiate-function-1.cpp | |
parent | 6404c420e51d79daf6dfcfb1382254ad617bffeb (diff) | |
download | bcm5719-llvm-2a2d00f041a2eca6453443fb4853816b63c12dcd.tar.gz bcm5719-llvm-2a2d00f041a2eca6453443fb4853816b63c12dcd.zip |
Template instantiation for switch statements
llvm-svn: 71916
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-function-1.cpp')
-rw-r--r-- | clang/test/SemaTemplate/instantiate-function-1.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-function-1.cpp b/clang/test/SemaTemplate/instantiate-function-1.cpp index 1dfe9e2da6a..abd0d1c0fbd 100644 --- a/clang/test/SemaTemplate/instantiate-function-1.cpp +++ b/clang/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}} |