Bug 97974 - [10 Regression] ICE tree check: expected overload, have function_decl in get_class_binding_direct, at cp/name-lookup.c:1332
Summary: [10 Regression] ICE tree check: expected overload, have function_decl in get_...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P2 normal
Target Milestone: 11.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2020-11-24 18:32 UTC by G. Steinmetz
Modified: 2023-07-07 09:13 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 11.0
Known to fail: 10.5.0
Last reconfirmed: 2020-11-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2020-11-24 18:32:36 UTC
Started with r8 before 20180525 :


$ cat z1.cc
struct {
  struct {
    operator int ();
    int a;
  };
  operator int;
};


$ g++-11-20201122 -c z1.cc
z1.cc:6:12: internal compiler error: tree check: expected overload, have function_decl in get_class_binding_direct, at cp/name-lookup.c:1332
    6 |   operator int
      |            ^~~
0x6520ba tree_check_failed(tree_node const*, char const*, int, char const*, ...)
        ../../gcc/tree.c:9810
0x7fad5a tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/tree.h:3317
0x7fad5a get_class_binding_direct(tree_node*, tree_node*, bool)
        ../../gcc/cp/name-lookup.c:1332
0x8ea66b lookup_field_r
        ../../gcc/cp/search.c:978
0x8e904e dfs_walk_all(tree_node*, tree_node* (*)(tree_node*, void*), tree_node* (*)(tree_node*, void*), void*)
        ../../gcc/cp/search.c:1408
0x8e91fc lookup_member(tree_node*, tree_node*, int, bool, int, access_failure_info*)
        ../../gcc/cp/search.c:1121
0x8e95a0 lookup_fnfields(tree_node*, tree_node*, int, int)
        ../../gcc/cp/search.c:1327
0x80aada lookup_name_1
        ../../gcc/cp/name-lookup.c:6587
0x80aada lookup_name(tree_node*, LOOK_where, LOOK_want)
        ../../gcc/cp/name-lookup.c:6665
0x811255 lookup_name(tree_node*, LOOK_want)
        ../../gcc/cp/name-lookup.h:294
0x811255 cp_parser_lookup_name
        ../../gcc/cp/parser.c:28864
0x818615 cp_parser_diagnose_invalid_type_name
        ../../gcc/cp/parser.c:3365
0x84a063 cp_parser_parse_and_diagnose_invalid_type_name
        ../../gcc/cp/parser.c:3619
0x860367 cp_parser_member_declaration
        ../../gcc/cp/parser.c:25456
0x82f722 cp_parser_member_specification_opt
        ../../gcc/cp/parser.c:25306
0x82f722 cp_parser_class_specifier_1
        ../../gcc/cp/parser.c:24395
0x832159 cp_parser_class_specifier
        ../../gcc/cp/parser.c:24706
0x832159 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17962
0x832d86 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14584
0x8339f1 cp_parser_simple_declaration
        ../../gcc/cp/parser.c:13841
Comment 1 Martin Liška 2020-11-25 08:11:27 UTC
Started to ICE with r8-7029-g35129fd3a745403b.
Comment 2 GCC Commits 2021-04-11 03:52:29 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:936d500dfc17f58f2507ecd0f7f26e4f197052ee

commit r11-8120-g936d500dfc17f58f2507ecd0f7f26e4f197052ee
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Apr 10 14:00:15 2021 -0400

    c++: ICE with anonymous union [PR97974]
    
    Here lookup got confused by finding a conversion operator from
    lookup_anon_field.  Let's avoid this by pruning functions from
    CLASSTYPE_MEMBER_VEC as well as TYPE_FIELDS.
    
    gcc/cp/ChangeLog:
    
            PR c++/97974
            * decl.c (fixup_anonymous_aggr): Prune all functions from
            CLASSTYPE_MEMBER_VEC.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/97974
            * g++.dg/lookup/pr84962.C: Adjust diagnostic.
            * g++.dg/other/anon-union5.C: New test.
Comment 3 Jason Merrill 2021-04-12 19:49:39 UTC
Fixed for 11 so far.
Comment 4 GCC Commits 2021-04-29 18:42:20 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:58a92b789a77cdade1f41800efebf6e0686f9982

commit r12-298-g58a92b789a77cdade1f41800efebf6e0686f9982
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Apr 10 14:00:15 2021 -0400

    c++: ICE with anonymous union [PR97974]
    
    While working on the GCC 11 patch, it occurred to me that we could move
    the errors about invalid members from finish_struct_anon_r to here, so we
    properly get a diagnostic in g++.law/union4.C.
    
    gcc/cp/ChangeLog:
    
            PR c++/97974
            * class.c (finish_struct_anon_r): Drop complain parm.
            Remove non-field diagnostic.
            (finish_struct_anon): Adjust.
            * decl.c (fixup_anonymous_aggr): Move non-field diagnostic here.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/97974
            * g++.old-deja/g++.law/union4.C: Add expected diagnostic.
Comment 5 Richard Biener 2021-06-01 08:19:05 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 6 Richard Biener 2022-05-27 09:43:53 UTC
GCC 9 branch is being closed
Comment 7 Jakub Jelinek 2022-06-28 10:42:32 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 8 Richard Biener 2023-07-07 09:13:40 UTC
Fixed in GCC 11.