32 lines · cpp
1// RUN: %clang_cc1 -std=c++1z -verify -emit-llvm-only %s2// expected-no-diagnostics3 4template <unsigned int BUFFER_SIZE> class Buffer {};5 6class A {7public:8 int status;9};10 11template <unsigned int N> A parse(Buffer<N> buffer);12 13template<unsigned int N>14void init_in_if(Buffer<N> buffer) {15 if (A a = parse(buffer); a.status > 0) {16 }17}18 19template<unsigned int N>20void init_in_switch(Buffer<N> buffer) {21 switch (A a = parse(buffer); a.status) {22 default:23 break;24 }25}26 27void test() {28 Buffer<10> buffer;29 init_in_if(buffer);30 init_in_switch(buffer);31}32