re PR c++/80471 ((gcc extension) Forwarding-reference `auto` function parameters...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 4 Oct 2017 21:25:20 +0000 (21:25 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 4 Oct 2017 21:25:20 +0000 (21:25 +0000)
2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/80471
* g++.dg/cpp1y/pr80471.C: New.

From-SVN: r253432

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr80471.C [new file with mode: 0644]

index b1e3edcb828a25c491e11277e7866b0ec067c2e7..bd4133b70ad7b80479941ebf8f8ba208a7ecc0a4 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/80471
+       * g++.dg/cpp1y/pr80471.C: New.
+
 2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
 
        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 (file)
index 0000000..bca4022
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/80471
+// { dg-do compile { target c++14 } }
+// { dg-options "" }
+
+template <class, class>
+constexpr bool is_same = false;
+template <class T>
+constexpr bool is_same<T, T> = true;
+
+template<class T>
+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& >, "");
+}