public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Subject: C++ PATCH for c++/89532 - ICE with incomplete type in decltype
Date: Thu, 28 Feb 2019 20:34:00 -0000	[thread overview]
Message-ID: <20190228200411.GK8512@redhat.com> (raw)

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

             reply	other threads:[~2019-02-28 20:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 20:34 Marek Polacek [this message]
2019-03-01 14:09 ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228200411.GK8512@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).