diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-04-05 17:05:03 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-04-05 17:05:03 +0000 |
commit | 3b4a12aa8a7c7298c0b6277dad82e1dd95857eb8 (patch) | |
tree | 9baede93c832fe05658a4eb44355dd4535496a77 | |
parent | 970d3d9011542639b420610a29bf9046fcee606c (diff) | |
download | gcc-3b4a12aa8a7c7298c0b6277dad82e1dd95857eb8.zip gcc-3b4a12aa8a7c7298c0b6277dad82e1dd95857eb8.tar.gz gcc-3b4a12aa8a7c7298c0b6277dad82e1dd95857eb8.tar.bz2 |
re PR c++/84792 (ICE with broken typedef of a struct)
/cp
2018-04-05 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84792
* decl.c (grokdeclarator): Fix diagnostic about typedef name used
as nested-name-specifier, keep type and TREE_TYPE (decl) in sync.
/testsuite
2018-04-05 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84792
* g++.dg/other/pr84792-1.C: New.
* g++.dg/other/pr84792-2.C: Likewise.
From-SVN: r259136
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/pr84792-1.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/pr84792-2.C | 6 |
5 files changed, 30 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a876dc9..0d60ed0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-05 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/84792 + * decl.c (grokdeclarator): Fix diagnostic about typedef name used + as nested-name-specifier, keep type and TREE_TYPE (decl) in sync. + 2018-04-05 Jason Merrill <jason@redhat.com> PR c++/82152 - ICE with class deduction and inherited ctor. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b2e509e..489dcc0 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11766,15 +11766,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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 45fecfb..a94044e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-04-05 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/84792 + * g++.dg/other/pr84792-1.C: New. + * g++.dg/other/pr84792-2.C: Likewise. + 2018-04-05 Uros Bizjak <ubizjak@gmail.com> PR target/85193 diff --git a/gcc/testsuite/g++.dg/other/pr84792-1.C b/gcc/testsuite/g++.dg/other/pr84792-1.C new file mode 100644 index 0000000..23df8ae --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr84792-1.C @@ -0,0 +1,6 @@ +struct A {}; + +typedef struct +{ + virtual void foo() {} +} A::B; // { dg-error "typedef" } diff --git a/gcc/testsuite/g++.dg/other/pr84792-2.C b/gcc/testsuite/g++.dg/other/pr84792-2.C new file mode 100644 index 0000000..a393d57 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr84792-2.C @@ -0,0 +1,6 @@ +struct A {}; + +typedef struct +{ + void foo() {} +} A::B; // { dg-error "typedef" } |