aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-03-09 17:22:46 -0500
committerJason Merrill <jason@redhat.com>2023-03-09 22:14:03 -0500
commit68c5d92a1390ecccb61d3600a95eeff6caf7ccdf (patch)
treee165f7819a0cc0720e958c8d233edae1bb0d7b0a
parentda2b9c6e310e808f73c5dcfb3f46ca70b836e8f5 (diff)
downloadgcc-68c5d92a1390ecccb61d3600a95eeff6caf7ccdf.zip
gcc-68c5d92a1390ecccb61d3600a95eeff6caf7ccdf.tar.gz
gcc-68c5d92a1390ecccb61d3600a95eeff6caf7ccdf.tar.bz2
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.
-rw-r--r--gcc/cp/class.cc2
-rw-r--r--gcc/testsuite/g++.dg/contracts/contracts-err1.C7
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 27a7982..d37e9d4 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 0000000..8437d94
--- /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" }