Message ID | 535f57c0-d193-adfc-a3b9-6a0407e0d731@oracle.com |
---|---|
State | New |
Headers | show |
Series | [C++] PR 84792 ("[6/7/8 Regression] ICE with broken typedef of a struct") | expand |
On Wed, Apr 4, 2018 at 8:48 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > I'm really happy to report that these 5 ugly lines are causing an actual > bug. Seriously, not considering the formatting, the problem is that we > really want to keep 'type' in sync, because we are using it below before > returning. Note that we don't regress location-wise because either > explicitly or implicitly we pass input_location anyway. Finishing testing on > x86_64-linux. Hmm, I wonder why we need to make the type error_mark_node at all, given that the problem is with the declarator. But this patch is OK. Jason
Index: cp/decl.c =================================================================== --- cp/decl.c (revision 259104) +++ cp/decl.c (working copy) @@ -11746,15 +11746,16 @@ grokdeclarator (const cp_declarator *declarator, if (reqs) error_at (location_of (reqs), "requires-clause on typedef"); + if (id_declarator && declarator->u.id.qualifying_scope) + { + error ("typedef name may not be a nested-name-specifier"); + type = error_mark_node; + } + if (decl_context == FIELD) decl = build_lang_decl (TYPE_DECL, unqualified_id, type); else decl = build_decl (input_location, TYPE_DECL, unqualified_id, type); - if (id_declarator && declarator->u.id.qualifying_scope) { - error_at (DECL_SOURCE_LOCATION (decl), - "typedef name may not be a nested-name-specifier"); - TREE_TYPE (decl) = error_mark_node; - } if (decl_context != FIELD) { Index: testsuite/g++.dg/other/pr84792-1.C =================================================================== --- testsuite/g++.dg/other/pr84792-1.C (nonexistent) +++ testsuite/g++.dg/other/pr84792-1.C (working copy) @@ -0,0 +1,6 @@ +struct A {}; + +typedef struct +{ + virtual void foo() {} +} A::B; // { dg-error "typedef" } Index: testsuite/g++.dg/other/pr84792-2.C =================================================================== --- testsuite/g++.dg/other/pr84792-2.C (nonexistent) +++ testsuite/g++.dg/other/pr84792-2.C (working copy) @@ -0,0 +1,6 @@ +struct A {}; + +typedef struct +{ + void foo() {} +} A::B; // { dg-error "typedef" }