public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6568] c++: overloaded fn in contract [PR108542]
Date: Fri, 10 Mar 2023 03:14:09 +0000 (GMT)	[thread overview]
Message-ID: <20230310031409.90AE738582BD@sourceware.org> (raw)

https://gcc.gnu.org/g:68c5d92a1390ecccb61d3600a95eeff6caf7ccdf

commit r13-6568-g68c5d92a1390ecccb61d3600a95eeff6caf7ccdf
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 9 17:22:46 2023 -0500

    c++: overloaded fn in contract [PR108542]
    
            PR c++/108542
    
    gcc/cp/ChangeLog:
    
            * class.cc (instantiate_type): Strip location wrapper.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/contracts/contracts-err1.C: New test.

Diff:
---
 gcc/cp/class.cc                                 | 2 ++
 gcc/testsuite/g++.dg/contracts/contracts-err1.C | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 27a79829737..d37e9d4d576 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -8728,6 +8728,8 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t complain)
 
   complain &= ~tf_ptrmem_ok;
 
+  STRIP_ANY_LOCATION_WRAPPER (rhs);
+
   if (lhstype == unknown_type_node)
     {
       if (complain & tf_error)
diff --git a/gcc/testsuite/g++.dg/contracts/contracts-err1.C b/gcc/testsuite/g++.dg/contracts/contracts-err1.C
new file mode 100644
index 00000000000..8437d94e2ad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/contracts/contracts-err1.C
@@ -0,0 +1,7 @@
+// PR c++/108542
+// { dg-additional-options -fcontracts }
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+void f (T n) {}
+void g() [[pre: f]];			// { dg-error "overloaded" }

                 reply	other threads:[~2023-03-10  3:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230310031409.90AE738582BD@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).