public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] c++: overloaded fn in contract [PR108542]
@ 2023-03-10  3:13 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-03-10  3:13 UTC (permalink / raw)
  To: gcc-patches

Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

	PR c++/108542

gcc/cp/ChangeLog:

	* class.cc (instantiate_type): Strip location wrapper.

gcc/testsuite/ChangeLog:

	* g++.dg/contracts/contracts-err1.C: New test.
---
 gcc/cp/class.cc                                 | 2 ++
 gcc/testsuite/g++.dg/contracts/contracts-err1.C | 7 +++++++
 2 files changed, 9 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/contracts/contracts-err1.C

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" }

base-commit: e0324e2629e25a90c13c68b4eef1e47b091970c3
-- 
2.31.1


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

only message in thread, other threads:[~2023-03-10  3:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10  3:13 [pushed] c++: overloaded fn in contract [PR108542] 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).