diff mbox

PR 66149 & PR78235 dbxout_type_fields

Message ID CAGWvnykUN3rC3PZHxRRa90mXJ9Nc2PCZBY__NUqyunV23PMRWw@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Dec. 1, 2016, 4:15 p.m. UTC
A number of the "variant" testcases fail to build on AIX and targets
that use stabs.  The failure looks like:

/tmp/GCC/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/variant:956:
internal compiler error: tree check: expected field_decl, have
template_decl in int_bit_position, at tree.h:5396

which occurs in dbxout_type_fields()

  /* Output the name, type, position (in bits), size (in bits) of each
     field that we can support.  */
  for (tem = TYPE_FIELDS (type); tem; tem = DECL_CHAIN (tem))
     ...
          if (VAR_P (tem))
            {
             ...
             }
          else
            {
              stabstr_C (',');
              stabstr_D (int_bit_position (tem));
              stabstr_C (',');
              stabstr_D (tree_to_uhwi (DECL_SIZE (tem)));
              stabstr_C (';');
            }

where tem is a TEMPLATE_DECL.  The dbxout code currently skips
TYPE_DECL, nameless fields, and CONST_DECL.

dbxout_type_methods() explicitly skips TEMPLATE_DECLs with the comment
"The debugger doesn't know what to do with such entities anyhow", so
this proposed patch skips them in dbxout_type_fields() as well.

Okay?

Thanks, David


PR debug/66419
PR c++/78235
* dbxout.c (dbxout_type_fields): Skip TEMPLATE_DECLs.

Comments

Jeff Law Dec. 1, 2016, 6:25 p.m. UTC | #1
On 12/01/2016 09:15 AM, David Edelsohn wrote:
> A number of the "variant" testcases fail to build on AIX and targets
> that use stabs.  The failure looks like:
>
> /tmp/GCC/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/variant:956:
> internal compiler error: tree check: expected field_decl, have
> template_decl in int_bit_position, at tree.h:5396
>
> which occurs in dbxout_type_fields()
>
>   /* Output the name, type, position (in bits), size (in bits) of each
>      field that we can support.  */
>   for (tem = TYPE_FIELDS (type); tem; tem = DECL_CHAIN (tem))
>      ...
>           if (VAR_P (tem))
>             {
>              ...
>              }
>           else
>             {
>               stabstr_C (',');
>               stabstr_D (int_bit_position (tem));
>               stabstr_C (',');
>               stabstr_D (tree_to_uhwi (DECL_SIZE (tem)));
>               stabstr_C (';');
>             }
>
> where tem is a TEMPLATE_DECL.  The dbxout code currently skips
> TYPE_DECL, nameless fields, and CONST_DECL.
>
> dbxout_type_methods() explicitly skips TEMPLATE_DECLs with the comment
> "The debugger doesn't know what to do with such entities anyhow", so
> this proposed patch skips them in dbxout_type_fields() as well.
>
> Okay?
>
> Thanks, David
>
>
> PR debug/66419
> PR c++/78235
> * dbxout.c (dbxout_type_fields): Skip TEMPLATE_DECLs.
 From the looks of things, it appears we skip them in the dwarf2 code as 
well.  But I don't think we can use TEMPLATE_DECL here as that's defined 
by the C++ front end.

I think instead if you test something like:
   (int)TREE_CODE (decl) > NUM_TREE_CODES

You'll filter out any _DECL nodes coming out of the front-ends.


jeff
David Edelsohn Dec. 1, 2016, 6:41 p.m. UTC | #2
On Thu, Dec 1, 2016 at 1:25 PM, Jeff Law <law@redhat.com> wrote:
> On 12/01/2016 09:15 AM, David Edelsohn wrote:
>>
>> A number of the "variant" testcases fail to build on AIX and targets
>> that use stabs.  The failure looks like:
>>
>> /tmp/GCC/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/variant:956:
>> internal compiler error: tree check: expected field_decl, have
>> template_decl in int_bit_position, at tree.h:5396
>>
>> which occurs in dbxout_type_fields()
>>
>>   /* Output the name, type, position (in bits), size (in bits) of each
>>      field that we can support.  */
>>   for (tem = TYPE_FIELDS (type); tem; tem = DECL_CHAIN (tem))
>>      ...
>>           if (VAR_P (tem))
>>             {
>>              ...
>>              }
>>           else
>>             {
>>               stabstr_C (',');
>>               stabstr_D (int_bit_position (tem));
>>               stabstr_C (',');
>>               stabstr_D (tree_to_uhwi (DECL_SIZE (tem)));
>>               stabstr_C (';');
>>             }
>>
>> where tem is a TEMPLATE_DECL.  The dbxout code currently skips
>> TYPE_DECL, nameless fields, and CONST_DECL.
>>
>> dbxout_type_methods() explicitly skips TEMPLATE_DECLs with the comment
>> "The debugger doesn't know what to do with such entities anyhow", so
>> this proposed patch skips them in dbxout_type_fields() as well.
>>
>> Okay?
>>
>> Thanks, David
>>
>>
>> PR debug/66419
>> PR c++/78235
>> * dbxout.c (dbxout_type_fields): Skip TEMPLATE_DECLs.
>
> From the looks of things, it appears we skip them in the dwarf2 code as
> well.  But I don't think we can use TEMPLATE_DECL here as that's defined by
> the C++ front end.

TEMPLATE_DECL is defined in cp/cp-tree.def, which is included in
all-tree.def, which is included in tree-core.h, which is included in
tree.h, which is included in dbxout.c.

It also is referenced in common code in gcc/tree.c.

> I think instead if you test something like:
>   (int)TREE_CODE (decl) > NUM_TREE_CODES
>
> You'll filter out any _DECL nodes coming out of the front-ends.

No other DECLs seem to escape.

- David
Jeff Law Dec. 1, 2016, 6:49 p.m. UTC | #3
On 12/01/2016 11:41 AM, David Edelsohn wrote:
> On Thu, Dec 1, 2016 at 1:25 PM, Jeff Law <law@redhat.com> wrote:
>> On 12/01/2016 09:15 AM, David Edelsohn wrote:
>>>
>>> A number of the "variant" testcases fail to build on AIX and targets
>>> that use stabs.  The failure looks like:
>>>
>>> /tmp/GCC/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/variant:956:
>>> internal compiler error: tree check: expected field_decl, have
>>> template_decl in int_bit_position, at tree.h:5396
>>>
>>> which occurs in dbxout_type_fields()
>>>
>>>   /* Output the name, type, position (in bits), size (in bits) of each
>>>      field that we can support.  */
>>>   for (tem = TYPE_FIELDS (type); tem; tem = DECL_CHAIN (tem))
>>>      ...
>>>           if (VAR_P (tem))
>>>             {
>>>              ...
>>>              }
>>>           else
>>>             {
>>>               stabstr_C (',');
>>>               stabstr_D (int_bit_position (tem));
>>>               stabstr_C (',');
>>>               stabstr_D (tree_to_uhwi (DECL_SIZE (tem)));
>>>               stabstr_C (';');
>>>             }
>>>
>>> where tem is a TEMPLATE_DECL.  The dbxout code currently skips
>>> TYPE_DECL, nameless fields, and CONST_DECL.
>>>
>>> dbxout_type_methods() explicitly skips TEMPLATE_DECLs with the comment
>>> "The debugger doesn't know what to do with such entities anyhow", so
>>> this proposed patch skips them in dbxout_type_fields() as well.
>>>
>>> Okay?
>>>
>>> Thanks, David
>>>
>>>
>>> PR debug/66419
>>> PR c++/78235
>>> * dbxout.c (dbxout_type_fields): Skip TEMPLATE_DECLs.
>>
>> From the looks of things, it appears we skip them in the dwarf2 code as
>> well.  But I don't think we can use TEMPLATE_DECL here as that's defined by
>> the C++ front end.
>
> TEMPLATE_DECL is defined in cp/cp-tree.def, which is included in
> all-tree.def, which is included in tree-core.h, which is included in
> tree.h, which is included in dbxout.c.
>
> It also is referenced in common code in gcc/tree.c.
In that case, do ahead with checking TEMPLATE_DECL.


>
>> I think instead if you test something like:
>>   (int)TREE_CODE (decl) > NUM_TREE_CODES
>>
>> You'll filter out any _DECL nodes coming out of the front-ends.
>
> No other DECLs seem to escape.
Good :-)

jeff
Jakub Jelinek Dec. 1, 2016, 10:10 p.m. UTC | #4
On Thu, Dec 01, 2016 at 01:41:30PM -0500, David Edelsohn wrote:
> TEMPLATE_DECL is defined in cp/cp-tree.def, which is included in
> all-tree.def, which is included in tree-core.h, which is included in
> tree.h, which is included in dbxout.c.

That is clearly a bug, if TEMPLATE_DECL is used in the generic code, it
should be moved into generic tree.def IMHO.
But of course it can be done incrementally.

	Jakub
diff mbox

Patch

Index: dbxout.c
===================================================================
--- dbxout.c    (revision 243118)
+++ dbxout.c    (working copy)
@@ -1479,6 +1479,7 @@  dbxout_type_fields (tree type)

       /* Omit here local type decls until we know how to support them.  */
       if (TREE_CODE (tem) == TYPE_DECL
+         || TREE_CODE (tem) == TEMPLATE_DECL
          /* Omit here the nameless fields that are used to skip bits.  */
          || DECL_IGNORED_P (tem)
          /* Omit fields whose position or size are variable or too large to