public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8758] c++: auto member function and auto variable [PR106893]
@ 2022-09-12 20:29 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-09-12 20:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:999638cb7b126d33d1ea6548c69ba387b7d7a270

commit r12-8758-g999638cb7b126d33d1ea6548c69ba387b7d7a270
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Sep 12 13:47:34 2022 -0400

    c++: auto member function and auto variable [PR106893]
    
    As with PR105623, we need to call mark_single_function sooner to
    resolve the type of a BASELINK.
    
            PR c++/106893
            PR c++/90451
    
    gcc/cp/ChangeLog:
    
            * decl.cc (cp_finish_decl): Call mark_single_function.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1y/auto-fn65.C: New test.

Diff:
---
 gcc/cp/decl.cc                         |  3 +++
 gcc/testsuite/g++.dg/cpp1y/auto-fn65.C | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 9f78c500a15..cd1522f9a9f 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -8137,6 +8137,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	    d_init = build_x_compound_expr_from_list (d_init, ELK_INIT,
 						      tf_warning_or_error);
 	  d_init = resolve_nondeduced_context (d_init, tf_warning_or_error);
+	  /* Force auto deduction now.  Use tf_none to avoid redundant warnings
+	     on deprecated-14.C.  */
+	  mark_single_function (d_init, tf_none);
 	}
       enum auto_deduction_context adc = adc_variable_type;
       if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl))
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn65.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn65.C
new file mode 100644
index 00000000000..78bb004303b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn65.C
@@ -0,0 +1,10 @@
+// PR c++/106893
+// { dg-do compile { target c++14 } }
+
+template <typename T>
+struct CoordTraits
+{
+  static auto GetX(T const &p) { return 1; }
+};
+typedef CoordTraits<int> Traits;
+static constexpr auto GetX = Traits::GetX;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-12 20:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 20:29 [gcc r12-8758] c++: auto member function and auto variable [PR106893] Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).