c++: overloaded fn in contract [PR108542]
authorJason Merrill <jason@redhat.com>
Thu, 9 Mar 2023 22:22:46 +0000 (17:22 -0500)
committerJason Merrill <jason@redhat.com>
Fri, 10 Mar 2023 03:14:03 +0000 (22:14 -0500)
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
gcc/testsuite/g++.dg/contracts/contracts-err1.C [new file with mode: 0644]

index 27a7982..d37e9d4 100644 (file)
@@ -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 (file)
index 0000000..8437d94
--- /dev/null
@@ -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" }