public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-04-29 5:31 jakub
0 siblings, 0 replies; 8+ messages in thread
From: jakub @ 2002-04-29 5:31 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, jason, meissner, nobody
Old Synopsis:
New Synopsis: dwarf2out ICE with typedef using attributes
State-Changed-From-To: open->analyzed
State-Changed-By: jakub
State-Changed-When: Mon Apr 29 05:31:49 2002
State-Changed-Why:
Simplified into:
--- gcc/testsuite/g++.dg/debug/debug6.C.jj Thu Aug 30 22:30:55 2001
+++ gcc/testsuite/g++.dg/debug/debug6.C Mon Apr 29 14:41:05 2002
@@ -0,0 +1,17 @@
+// PR debug/6436
+// { dg-do compile }
+
+typedef struct
+{
+ unsigned int a0, a1;
+} A __attribute__ ((aligned(8)));
+
+typedef struct
+{
+ A a;
+} B;
+
+struct C
+{
+ B *bp;
+};
Regression from 2.9x (even with -gdwarf-2).
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6436
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-05-01 3:20 jason
0 siblings, 0 replies; 8+ messages in thread
From: jason @ 2002-05-01 3:20 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, jason, jason, meissner
Synopsis: dwarf2out ICE with typedef using attributes
State-Changed-From-To: analyzed->closed
State-Changed-By: jason
State-Changed-When: Wed May 1 03:19:57 2002
State-Changed-Why:
Fixed.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6436
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-04-30 10:56 Jason Merrill
0 siblings, 0 replies; 8+ messages in thread
From: Jason Merrill @ 2002-04-30 10:56 UTC (permalink / raw)
To: jason; +Cc: gcc-prs
The following reply was made to PR debug/6436; it has been noted by GNATS.
From: Jason Merrill <jason@redhat.com>
To: Daniel Berlin <dberlin@dberlin.org>
Cc: jakub@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <meissner@suse.de>,
<gcc-gnats@gcc.gnu.org>, <gcc-patches@gcc.gnu.org>,
Mark Mitchell <mark@codesourcery.com>,
Richard Sandiford <rsandifo@redhat.com>
Subject: Re: debug/6436: dwarf2out ICE with typedef using attributes
Date: Tue, 30 Apr 2002 18:48:33 +0100
--=-=-=
>>>>> "Jason" == Jason Merrill <jason@redhat.com> writes:
> One fix would be to not give the name 'A' to the anonymous struct.
Thus. I've added Jakub's testcase to the testsuite as
g++.dg/debug/typedef1.C.
Booted and tested i686-pc-linux-gnu, applied trunk and 3.1.
2002-04-30 Jason Merrill <jason@redhat.com>
* decl.c (grokdeclarator): Don't override TYPE_NAME of an
anonymous class with a typedef if there are attributes.
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline
*** decl.c.~1~ Tue Apr 30 14:06:13 2002
--- decl.c Tue Apr 30 18:21:09 2002
*************** grokdeclarator (declarator, declspecs, d
*** 11275,11280 ****
--- 11275,11282 ----
&& TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& TYPE_ANONYMOUS_P (type)
+ /* Don't do this if there are attributes. */
+ && (!attrlist || !*attrlist)
&& cp_type_quals (type) == TYPE_UNQUALIFIED)
{
tree oldname = TYPE_NAME (type);
--=-=-=--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-04-30 5:36 Jason Merrill
0 siblings, 0 replies; 8+ messages in thread
From: Jason Merrill @ 2002-04-30 5:36 UTC (permalink / raw)
To: jason; +Cc: gcc-prs
The following reply was made to PR debug/6436; it has been noted by GNATS.
From: Jason Merrill <jason@redhat.com>
To: Daniel Berlin <dberlin@dberlin.org>
Cc: jakub@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <meissner@suse.de>,
<gcc-gnats@gcc.gnu.org>, <gcc-patches@gcc.gnu.org>,
Mark Mitchell <mark@codesourcery.com>,
Richard Sandiford <rsandifo@redhat.com>
Subject: Re: debug/6436: dwarf2out ICE with typedef using attributes
Date: Tue, 30 Apr 2002 11:01:51 +0100
>>>>> "Daniel" == Daniel Berlin <dberlin@dberlin.org> writes:
> For C++, we output two *named* types first, ._0, which is the A *without*
> alignment, then ._1, which is the A *with* alignment.
Actually, ._1 is B. The C++ standard says
If the typedef declaration defines an unnamed class (or enum), the
first typedef-name declared by the declaration to be that class type
(or enum type) is used to denote the class type (or enum type) for
linkage purposes only.
So we set TYPE_NAME for the type to be the typedef, rather than the funny
internal name. For B this is fine, because the type of the name B is the
struct itself. For A we have a problem: the type of the name A is an
attribute-variant of the anonymous struct, but we set the struct's name
anyway. So
TREE_TYPE (TYPE_NAME (type)) != type
but
DECL_ORIGINAL_TYPE (TYPE_NAME (type)) == type
One fix would be to not give the name 'A' to the anonymous struct.
However, that would mean that we couldn't use the type in a mangled
context, and I suspect that there is code out there that relies on this
sort of pattern, though I suppose it's easy enough to fix affected code by
adding an "A" after the "struct" tag.
Jason
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-04-29 11:36 Daniel Berlin
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Berlin @ 2002-04-29 11:36 UTC (permalink / raw)
To: jason; +Cc: gcc-prs
The following reply was made to PR debug/6436; it has been noted by GNATS.
From: Daniel Berlin <dberlin@dberlin.org>
To: Jason Merrill <jason@redhat.com>
Cc: jakub@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <meissner@suse.de>,
<gcc-gnats@gcc.gnu.org>, <gcc-patches@gcc.gnu.org>,
Mark Mitchell <mark@codesourcery.com>,
Richard Sandiford <rsandifo@redhat.com>
Subject: Re: debug/6436: dwarf2out ICE with typedef using attributes
Date: Mon, 29 Apr 2002 14:32:14 -0400 (EDT)
On Mon, 29 Apr 2002, Jason Merrill wrote:
> This fix seems reasonable; I'll apply it after testing. I'm a bit
> uncomfortable with the typedef pointing to its own type, though; what do
> other people think the effect of Jakub's testcase should be?
>
> Richard Sandiford's recent patch tries to deal with this sort of situation
> by separating the typedef type and underlying struct type; why isn't that
> working here?
>
Here's a kicker, probably related: The exact code in question works
perfectly in C. IE run jakub's test under cc1, and it does fine.
In fact, I was about to email Jakub saying i couldn't reproduce, wwhne i
noticed the original testcase was in C++. So i tried cc1plus, and boom.
Analyzing what goes right in C:
We start the same path, getting the member_declared_type of a, seeing it's
A, and going to output a type die for A *with* alignment.
It gets the main variant, which, just like C++, is A *without* alignment.
...
Okay, well, by that point, the A *without* alignment is already written
out, so it returns right there.
Which is the difference and why C works.
SO let me back up.
The first type we output for C is an unnamed type that is A *without*
alignment.
I.E. TYPE_NAME (type) == NULL
It's output from finish_struct, which calls rest_of_type_compilation,
which calls dwarf2out_decl (TYPE_STUB_DECL (type)).
Then we output unsigned int, then another unnamed type that is A with
alignment.
Then we get to output A, whose main variant is the *unnamed* type we wrote
out before. Thus, TYPE_NAME (type) == NULL, and we go about our merry
way.
So it works fine.
For C++, we output two *named* types first, ._0, which is the A *without*
alignment, then ._1, which is the A *with* alignment.
I.E. TYPE_NAME (type) != NULL on either of them.
Eventually we go to output A, whose main variant is not either of the
named type, but another type named "A" without the alignment.
This is what starts the dominoes falling.
If the main variant of A was ._0, we should be fine.
Or, if we output the second "A" type that seemed to materialize out of
nowhere, before trying to output the real "A", we'd be fine.
My gut feeling is the main variant of A with alignment should be ._0, not
this other type named "A" without alignment that seemed to materialize out
of nowhere, and was never output.
But this is just because it "feels" right, and what C does.
I may be completely wrong.
> 2002-04-29 Jason Merrill <jason@redhat.com>
>
> * dwarf2out.c (gen_type_die): Don't recurse on a self-referential
> typedef.
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-04-29 10:56 Jason Merrill
0 siblings, 0 replies; 8+ messages in thread
From: Jason Merrill @ 2002-04-29 10:56 UTC (permalink / raw)
To: jason; +Cc: gcc-prs
The following reply was made to PR debug/6436; it has been noted by GNATS.
From: Jason Merrill <jason@redhat.com>
To: Daniel Berlin <dberlin@dberlin.org>
Cc: jakub@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <meissner@suse.de>,
<gcc-gnats@gcc.gnu.org>, gcc-patches@gcc.gnu.org,
Mark Mitchell <mark@codesourcery.com>,
Richard Sandiford <rsandifo@redhat.com>
Subject: Re: debug/6436: dwarf2out ICE with typedef using attributes
Date: Mon, 29 Apr 2002 18:47:02 +0100
--=-=-=
This fix seems reasonable; I'll apply it after testing. I'm a bit
uncomfortable with the typedef pointing to its own type, though; what do
other people think the effect of Jakub's testcase should be?
Richard Sandiford's recent patch tries to deal with this sort of situation
by separating the typedef type and underlying struct type; why isn't that
working here?
2002-04-29 Jason Merrill <jason@redhat.com>
* dwarf2out.c (gen_type_die): Don't recurse on a self-referential
typedef.
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline
*** dwarf2out.c.~1~ Mon Apr 29 18:39:20 2002
--- dwarf2out.c Mon Apr 29 18:15:37 2002
*************** gen_type_die (type, context_die)
*** 11068,11074 ****
return;
if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
! && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
{
TREE_ASM_WRITTEN (type) = 1;
gen_decl_die (TYPE_NAME (type), context_die);
--- 11068,11075 ----
return;
if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
! && DECL_ORIGINAL_TYPE (TYPE_NAME (type))
! && DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type)
{
TREE_ASM_WRITTEN (type) = 1;
gen_decl_die (TYPE_NAME (type), context_die);
--=-=-=--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-04-29 10:36 Daniel Berlin
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Berlin @ 2002-04-29 10:36 UTC (permalink / raw)
To: jason; +Cc: gcc-prs
The following reply was made to PR debug/6436; it has been noted by GNATS.
From: Daniel Berlin <dberlin@dberlin.org>
To: jakub@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>,
<jason@redhat.com>, <meissner@suse.de>, <nobody@gcc.gnu.org>,
<gcc-gnats@gcc.gnu.org>, <jason@redhat.com>
Cc:
Subject: Re: debug/6436: dwarf2out ICE with typedef using attributes
Date: Mon, 29 Apr 2002 13:31:54 -0400 (EDT)
This one is fun. Not playing beach volley ball fun, more like
burning yourself on hot coals fun.
Here's what happens:
We go to output a type die for A *with* alignment, because it's the type
of a decl.
In gen_type_die, we first get the main variant of A, which is an A
*without* the user set alignment.
We then hit this test near the top:
if (TYPE_NAME (decl) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL &&
DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
and it succeeds, causing us to do:
{
<type is now a without alignment, type_name (type) is a with alignment>
TREE_ASM_WRITTEN (type) = 1;
gen_decl_die (TYPE_NAME (type), context_die);
return;
}
So we mark the A *without* alignment as written, then proceed to try to
gen a decl die for the type_name of A, which is just like A, only *with*
the alignment. (you should already smell trouble brewing here, since this
whole thing started when we were trying to output a type die for A *with*
alignment, and surely, gen_decl_die will try to do this as well)
is_redundant_typedef on it says no, so we go to gen a typedef die for the
A with alignment, to the A without alignment.
In gen_typedef_die, first we mark the A with alignment type as written,
then proceed to get the original type, A *without* alignment, and ask
modified_type_die for a type die with the qualifiers in front of it, if
any.
In the portion of modified_type_die labeled "Handle C typedef types", we
pass the main test, but qualified_type != dtype because one is the one
with alignment, one is the one without ailgnment, thus, they are
different trees, and the pointer comparison fails. Even though, going
by qualifications, they *are* the same type.
After failing that, we fail the other tests, getting us to the else which
calls gen_type_die, with the type passed in (This is the A without
alignment type, once again).
Which of course, sees it's written the type (since we set the written flag
on that one at the beginning of this godawful trip through hell), and
returns.
The lookup, which should succeed, and would, had we actually ever written
the original type, instead of us taking this trip to the 9th circle,
fails, and we abort.
To be more concise, here's what happens:
gen_type_die (A with alignment)
|
get main variant, A *without* alignment, see it's got a type name,
therefore, so mark A *without* alignment as written, and call
|
gen_decl_die (TYPE_NAME (A without alignment), which is A with alignment)
|
is_redundant == no, so
|
gen_typedef (A with alignment)
|
Mark A with alignment as written.
|
Notice A with alignment has an original type, get original type, A
*without* alignment.
|
modified_type_die (A *without* alignment)
|
fail test saying it's equal to existing qualified type, causing us to:
|
gen_type_die (A *without* alignment)
|
Sees it's marked as written, so it just returns.
|
lookup fails, since we really haven't written it (we are in the process of
trying to write it, we will when we get back up to the top of the
recursion chain), and we abort.
My head hurts.
I'm not sure what the right thing to do in this case is, so i'm not sure i
can point out a stage and say "That's where it all went wrong". But
someone who *does* understand what we should do, should be able to use
this analysis to fix the problem.
--Dan
yet. On 29 Apr 2002 jakub@gcc.gnu.org
wrote:
> Old Synopsis:
> New Synopsis: dwarf2out ICE with typedef using attributes
>
> State-Changed-From-To: open->analyzed
> State-Changed-By: jakub
> State-Changed-When: Mon Apr 29 05:31:49 2002
> State-Changed-Why:
> Simplified into:
> --- gcc/testsuite/g++.dg/debug/debug6.C.jj Thu Aug 30 22:30:55 2001
> +++ gcc/testsuite/g++.dg/debug/debug6.C Mon Apr 29 14:41:05 2002
> @@ -0,0 +1,17 @@
> +// PR debug/6436
> +// { dg-do compile }
> +
> +typedef struct
> +{
> + unsigned int a0, a1;
> +} A __attribute__ ((aligned(8)));
> +
> +typedef struct
> +{
> + A a;
> +} B;
> +
> +struct C
> +{
> + B *bp;
> +};
>
> Regression from 2.9x (even with -gdwarf-2).
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6436
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: debug/6436: dwarf2out ICE with typedef using attributes
@ 2002-04-29 10:09 jason
0 siblings, 0 replies; 8+ messages in thread
From: jason @ 2002-04-29 10:09 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, jason, jason, meissner, nobody
Synopsis: dwarf2out ICE with typedef using attributes
Responsible-Changed-From-To: unassigned->jason
Responsible-Changed-By: jason
Responsible-Changed-When: Mon Apr 29 10:09:02 2002
Responsible-Changed-Why:
got it
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6436
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-05-01 10:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-29 5:31 debug/6436: dwarf2out ICE with typedef using attributes jakub
2002-04-29 10:09 jason
2002-04-29 10:36 Daniel Berlin
2002-04-29 10:56 Jason Merrill
2002-04-29 11:36 Daniel Berlin
2002-04-30 5:36 Jason Merrill
2002-04-30 10:56 Jason Merrill
2002-05-01 3:20 jason
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).