From 5b93c0eede070f8f3a6ce4a394937311c33df550 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 4 Oct 2017 21:25:20 +0000 Subject: [PATCH] re PR c++/80471 ((gcc extension) Forwarding-reference `auto` function parameters do not follow the same rules as template functions or generic lambdas) 2017-10-04 Paolo Carlini PR c++/80471 * g++.dg/cpp1y/pr80471.C: New. From-SVN: r253432 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/pr80471.C | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr80471.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b1e3edcb828..bd4133b70ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-04 Paolo Carlini + + PR c++/80471 + * g++.dg/cpp1y/pr80471.C: New. + 2017-10-04 Paolo Carlini PR c++/78131 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr80471.C b/gcc/testsuite/g++.dg/cpp1y/pr80471.C new file mode 100644 index 00000000000..bca4022cf57 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr80471.C @@ -0,0 +1,23 @@ +// PR c++/80471 +// { dg-do compile { target c++14 } } +// { dg-options "" } + +template +constexpr bool is_same = false; +template +constexpr bool is_same = true; + +template +decltype(auto) f(T&& a){return a;} + +decltype(auto) g(auto&& a){return a;} + +auto z = [](auto&& a) -> decltype(auto) { return a; }; + +int main() +{ + int i; + static_assert(is_same< decltype(f(i)), int& >, ""); + static_assert(is_same< decltype(g(i)), int >, ""); + static_assert(is_same< decltype(z(i)), int& >, ""); +} -- 2.30.2