public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>, Mark Mitchell <mark@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [C++ PATCH] Avoid decl_attributes on error_mark_node (PR c++/34100)
Date: Thu, 15 Nov 2007 15:07:00 -0000	[thread overview]
Message-ID: <20071115124624.GS5451@devserv.devel.redhat.com> (raw)

Hi!

On this testcase decl_attributes is called with a TYPE_DECL with
error_mark_node type, which most of the attribute handlers aren't prepared
to handle.  decl_attributes for attributes which require type will use
TREE_TYPE (decl) and all the handle_*_attribute routines expect that if
they require a type they will see a type rather than something else.
I have tried to return error_mark_node from tsubst_decl for TYPE_DECLs
where type == error_mark_node (which it already does for e.g. VAR_DECL
with type == error_mark_node), but that caused a bunch of testsuite
regressions, so I think it is better to leave that as is and catch the
problem either in apply_late_template_attributes, or in that function's
callers.

Regtested on x86_64-linux, ok for trunk?

2007-11-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/34100
	* pt.c (apply_late_template_attributes): Do nothing if decl's type is
	error_mark_node.

	* g++.dg/template/crash73.C: New test.

--- gcc/cp/pt.c.jj	2007-11-15 09:29:48.000000000 +0100
+++ gcc/cp/pt.c	2007-11-15 09:40:54.000000000 +0100
@@ -6622,7 +6622,11 @@ apply_late_template_attributes (tree *de
       }
 
   if (DECL_P (*decl_p))
-    p = &DECL_ATTRIBUTES (*decl_p);
+    {
+      if (TREE_TYPE (*decl_p) == error_mark_node)
+	return;
+      p = &DECL_ATTRIBUTES (*decl_p);
+    }
   else
     p = &TYPE_ATTRIBUTES (*decl_p);
 
--- gcc/testsuite/g++.dg/template/crash73.C.jj	2007-11-15 11:22:11.000000000 +0100
+++ gcc/testsuite/g++.dg/template/crash73.C	2007-11-15 11:22:02.000000000 +0100
@@ -0,0 +1,9 @@
+// PR c++/34100
+// { dg-do compile }
+
+template<typename T> struct A
+{
+  typedef typename T::X Y __attribute__((vector_size(8)));	// { dg-error "is not a class, struct" }
+};
+
+A<int> a;

	Jakub

             reply	other threads:[~2007-11-15 12:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-15 15:07 Jakub Jelinek [this message]
2007-11-16  4:37 ` Mark Mitchell

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=20071115124624.GS5451@devserv.devel.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=mark@codesourcery.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).