public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request
@ 2018-12-07  0:19 Alexandre Oliva
  2018-12-14 20:16 ` Alexandre Oliva
  2018-12-14 20:31 ` [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request Jason Merrill
  0 siblings, 2 replies; 4+ messages in thread
From: Alexandre Oliva @ 2018-12-07  0:19 UTC (permalink / raw)
  To: gcc-patches

tsubst_expr and tsubst_copy_and_build are not expected to handle
DEFERRED_NOEXCEPT exprs, but if tsubst_exception_specification takes a
DEFERRED_NOEXCEPT expr with !defer_ok, it just passes the expr on for
tsubst_copy_and_build to barf.

This patch arranges for tsubst_exception_specification to combine the
incoming args with those already stored in a DEFERRED_NOEXCEPT, and
then substitute them into the pattern, when retaining a deferred
noexcept is unacceptable.

Regstrapped on x86_64- and i686-linux-gnu, mistakenly along with a patch
with a known regression, and got only that known regression.  Retesting
without it.  Ok to install?


for  gcc/cp/ChangeLog

	PR c++/87814
	* pt.c (tsubst_exception_specification): Handle
	DEFERRED_NOEXCEPT with !defer_ok.

for  gcc/testsuite/ChangeLog

	PR c++/87814
	* g++.dg/cpp1z/pr87814.C: New.
---
 gcc/cp/pt.c                          |   14 +++++++++++---
 gcc/testsuite/g++.dg/cpp1z/pr87814.C |   26 ++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1z/pr87814.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8560e5885933..72ae7173d92c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14150,9 +14150,17 @@ tsubst_exception_specification (tree fntype,
 	    }
 	}
       else
-	new_specs = tsubst_copy_and_build
-	  (expr, args, complain, in_decl, /*function_p=*/false,
-	   /*integral_constant_expression_p=*/true);
+	{
+	  if (DEFERRED_NOEXCEPT_SPEC_P (specs))
+	    {
+	      args = add_to_template_args (DEFERRED_NOEXCEPT_ARGS (expr),
+					   args);
+	      expr = DEFERRED_NOEXCEPT_PATTERN (expr);
+	    }
+	  new_specs = tsubst_copy_and_build
+	    (expr, args, complain, in_decl, /*function_p=*/false,
+	     /*integral_constant_expression_p=*/true);
+	}
       new_specs = build_noexcept_spec (new_specs, complain);
     }
   else if (specs)
diff --git a/gcc/testsuite/g++.dg/cpp1z/pr87814.C b/gcc/testsuite/g++.dg/cpp1z/pr87814.C
new file mode 100644
index 000000000000..37034bb58cd6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/pr87814.C
@@ -0,0 +1,26 @@
+// { dg-do compile { target c++17 } }
+
+template<class Element>
+struct box {
+    template<class E>
+    constexpr box(E && e)
+        noexcept(noexcept(Element(e)))
+    {}
+};
+
+template<class... Ts>
+struct compressed_tuple_ : box<Ts> ... {
+    template<typename... Args>
+    constexpr compressed_tuple_(Args &&... args)
+        noexcept((noexcept(box<Ts>(args)) && ...))
+      : box<Ts>(args)...
+    {}
+};
+
+struct adaptor_cursor : compressed_tuple_<int*> {
+    using compressed_tuple_::compressed_tuple_;
+};
+
+int main() {
+    (void)noexcept(adaptor_cursor{(int*)0});
+}

-- 
Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
Be the change, be Free!         FSF Latin America board member
GNU Toolchain Engineer                Free Software Evangelist
Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request
  2018-12-07  0:19 [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request Alexandre Oliva
@ 2018-12-14 20:16 ` Alexandre Oliva
  2018-12-21 12:25   ` [committed] Add testcase for already fixed PR c++/87125 Jakub Jelinek
  2018-12-14 20:31 ` [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request Jason Merrill
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Oliva @ 2018-12-14 20:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, nathan

On Dec  6, 2018, Alexandre Oliva <aoliva@redhat.com> wrote:

> Regstrapped on x86_64- and i686-linux-gnu, mistakenly along with a patch
> with a known regression, and got only that known regression.  Retesting
> without it.  Ok to install?

Ping?  That retesting confirmed no regressions.
https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00423.html


> for  gcc/cp/ChangeLog

> 	PR c++/87814
> 	* pt.c (tsubst_exception_specification): Handle
> 	DEFERRED_NOEXCEPT with !defer_ok.

> for  gcc/testsuite/ChangeLog

> 	PR c++/87814
> 	* g++.dg/cpp1z/pr87814.C: New.

-- 
Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
Be the change, be Free!         FSF Latin America board member
GNU Toolchain Engineer                Free Software Evangelist
Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request
  2018-12-07  0:19 [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request Alexandre Oliva
  2018-12-14 20:16 ` Alexandre Oliva
@ 2018-12-14 20:31 ` Jason Merrill
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2018-12-14 20:31 UTC (permalink / raw)
  To: Alexandre Oliva, gcc-patches

On 12/6/18 7:19 PM, Alexandre Oliva wrote:
> tsubst_expr and tsubst_copy_and_build are not expected to handle
> DEFERRED_NOEXCEPT exprs, but if tsubst_exception_specification takes a
> DEFERRED_NOEXCEPT expr with !defer_ok, it just passes the expr on for
> tsubst_copy_and_build to barf.
> 
> This patch arranges for tsubst_exception_specification to combine the
> incoming args with those already stored in a DEFERRED_NOEXCEPT, and
> then substitute them into the pattern, when retaining a deferred
> noexcept is unacceptable.
> 
> Regstrapped on x86_64- and i686-linux-gnu, mistakenly along with a patch
> with a known regression, and got only that known regression.  Retesting
> without it.  Ok to install?

OK.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [committed] Add testcase for already fixed PR c++/87125
  2018-12-14 20:16 ` Alexandre Oliva
@ 2018-12-21 12:25   ` Jakub Jelinek
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2018-12-21 12:25 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches, jason, nathan

On Fri, Dec 14, 2018 at 06:15:54PM -0200, Alexandre Oliva wrote:
> On Dec  6, 2018, Alexandre Oliva <aoliva@redhat.com> wrote:
> 
> > Regstrapped on x86_64- and i686-linux-gnu, mistakenly along with a patch
> > with a known regression, and got only that known regression.  Retesting
> > without it.  Ok to install?
> 
> Ping?  That retesting confirmed no regressions.
> https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00423.html
> 
> 
> > for  gcc/cp/ChangeLog
> 
> > 	PR c++/87814
> > 	* pt.c (tsubst_exception_specification): Handle
> > 	DEFERRED_NOEXCEPT with !defer_ok.
> 
> > for  gcc/testsuite/ChangeLog
> 
> > 	PR c++/87814
> > 	* g++.dg/cpp1z/pr87814.C: New.

This patch fixed also PR87125, I've added the simplified testcase to
the testsuite after verifying it still ICEs before your commit and doesn't
after it or before r261084, so that we can close the PR.

2018-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/87125
	* g++.dg/cpp0x/pr87125.C: New test.

--- gcc/testsuite/g++.dg/cpp0x/pr87125.C.jj	2018-12-21 13:03:02.781212081 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr87125.C	2018-12-21 13:08:10.941433896 +0100
@@ -0,0 +1,15 @@
+// PR c++/87125
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct S {
+  template <typename U>
+  constexpr S (U) noexcept (T ()) {}
+};
+struct V : S<int> { using S::S; };
+
+bool
+foo ()
+{
+  return noexcept (V (0));
+}


	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-21 12:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07  0:19 [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request Alexandre Oliva
2018-12-14 20:16 ` Alexandre Oliva
2018-12-21 12:25   ` [committed] Add testcase for already fixed PR c++/87125 Jakub Jelinek
2018-12-14 20:31 ` [C++ PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request 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).