public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/89532 - ICE with incomplete type in decltype
@ 2019-02-28 20:34 Marek Polacek
  2019-03-01 14:09 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2019-02-28 20:34 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill

If get_target_expr_sfinae gets an expression whose type is incomplete, it's
upset.  digest_init returns error_mark_node if it gets an expression with
incomplete type, so we need to respect that, and not call
get_target_expr_sfinae on ORIG_CL in that case.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2019-02-28  Marek Polacek  <polacek@redhat.com>

	PR c++/89532 - ICE with incomplete type in decltype.
	* semantics.c (finish_compound_literal): Return error_mark_node
	if digest_init_flags returns error_mark_node.

	* g++.dg/cpp2a/nontype-class14.C: New test.

diff --git gcc/cp/semantics.c gcc/cp/semantics.c
index d1a378acd98..c03e4ef247c 100644
--- gcc/cp/semantics.c
+++ gcc/cp/semantics.c
@@ -2859,6 +2859,9 @@ finish_compound_literal (tree type, tree compound_literal,
   compound_literal = digest_init_flags (type, compound_literal,
 					LOOKUP_NORMAL | LOOKUP_NO_NARROWING,
 					complain);
+  if (compound_literal == error_mark_node)
+    return error_mark_node;
+
   /* If we're in a template, return the original compound literal.  */
   if (orig_cl)
     {
diff --git gcc/testsuite/g++.dg/cpp2a/nontype-class14.C gcc/testsuite/g++.dg/cpp2a/nontype-class14.C
new file mode 100644
index 00000000000..4b19f81f97a
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp2a/nontype-class14.C
@@ -0,0 +1,10 @@
+// PR c++/89532
+// { dg-do compile { target c++2a } }
+
+struct tuple;
+
+template <decltype(tuple {})> // { dg-error "invalid use of incomplete type" }
+struct S { };
+
+template<typename>
+decltype(tuple {}) d; // { dg-error "invalid use of incomplete type" }

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

* Re: C++ PATCH for c++/89532 - ICE with incomplete type in decltype
  2019-02-28 20:34 C++ PATCH for c++/89532 - ICE with incomplete type in decltype Marek Polacek
@ 2019-03-01 14:09 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-03-01 14:09 UTC (permalink / raw)
  To: Marek Polacek, GCC Patches

On 2/28/19 3:04 PM, Marek Polacek wrote:
> If get_target_expr_sfinae gets an expression whose type is incomplete, it's
> upset.  digest_init returns error_mark_node if it gets an expression with
> incomplete type, so we need to respect that, and not call
> get_target_expr_sfinae on ORIG_CL in that case.

> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2019-02-28  Marek Polacek  <polacek@redhat.com>
> 
> 	PR c++/89532 - ICE with incomplete type in decltype.
> 	* semantics.c (finish_compound_literal): Return error_mark_node
> 	if digest_init_flags returns error_mark_node.

OK.

Jason

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

end of thread, other threads:[~2019-03-01 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-28 20:34 C++ PATCH for c++/89532 - ICE with incomplete type in decltype Marek Polacek
2019-03-01 14:09 ` 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).