diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp1y')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/constexpr-84192.C | 41 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/pr84496.C | 44 |
3 files changed, 102 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-84192.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-84192.C new file mode 100644 index 00000000000..ad9458d238f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-84192.C @@ -0,0 +1,41 @@ +// PR c++/84192 +// { dg-do compile { target c++14 } } +// { dg-options "" } + +bool +f1 () +{ + return ({ return true; }) && false; // { dg-error "could not convert" } +} + +void +f2 () +{ + for (;;) + constexpr bool b = ({ break; false; }) && false; // { dg-error "statement is not a constant expression" } +} + +constexpr bool +f3 (int n) +{ + bool b = false; + for (int i = 0; i < n; i++) + b = ({ break; }); // { dg-error "void value not ignored as it ought to be" } + return b; +} + +constexpr bool b = f3 (4); + +bool +f4 () +{ + constexpr bool b = ({ return true; }) && false; // { dg-error "could not convert" } + return false; +} + +constexpr bool +f5 (int x) +{ + constexpr bool b = ({ switch (x) case 0: true; }) && false; // { dg-error "could not convert" } + return false; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C new file mode 100644 index 00000000000..76567966293 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C @@ -0,0 +1,17 @@ +// PR c++/84368 +// { dg-do compile { target c++14 } } + +template < typename ... T > +void sink(T ...){} + +template < typename ... T > +void foo(T ... v){ + [](auto ... v){ + auto bar = [](auto, auto){ return 0; }; + sink(bar(v, T{}) ...); + }(v ...); +} + +int main(){ + foo(0); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/pr84496.C b/gcc/testsuite/g++.dg/cpp1y/pr84496.C new file mode 100644 index 00000000000..028d00235cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr84496.C @@ -0,0 +1,44 @@ +// PR c++/84496 +// { dg-do compile { target c++14 } } + +template <typename T, T n> struct C { static constexpr T D = n; }; +struct E : C<bool, false> {}; +template <typename> struct F : C<bool, false> {}; +template <typename T> T foo (); +template <typename> struct H { typedef int G; }; +template <typename> class I; +struct L; +template <typename, typename> struct J; +template <bool, bool, typename...> struct K; +struct R { + template <typename M, typename... N> + static J<decltype (foo<M> () (foo<N>...)), L> o; +}; +template <typename P, typename... Q> struct K<false, false, P, Q...> : R { + typedef decltype (o<P, Q...>) G; +}; +template <typename P, typename... Q> +struct D : K<E::D, F<typename H<P>::G>::D, P, Q...> {}; +template <typename P, typename... Q> struct I<P (Q...)> : D<P, Q...> {}; +template <typename> class function; +template <typename S, typename... Q> struct function<S (Q...)> { + template <typename T, typename = typename I<T (Q...)>::G> struct C; + template <typename, typename> using U = int; + template <typename P, typename = U<int, void>, typename = U<C<P>, void>> + function (P); +}; +template <typename S, typename... Q> +template <typename P, typename, typename> +function<S (Q...)>::function (P) +{ +} +void bar (function<void (int)>); + +void +baz () +{ + auto a = [] { + static int counter; + bar ([] (auto) { counter++; }); + }; +} |