From: Paolo Carlini Date: Mon, 4 Mar 2019 23:49:23 +0000 (+0000) Subject: re PR c++/84605 (internal compiler error: in xref_basetypes, at cp/decl.c:13818) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b65e6a997761f03fe84ebe837201c51fe8bc2e2f;p=gcc.git re PR c++/84605 (internal compiler error: in xref_basetypes, at cp/decl.c:13818) /cp 2019-03-04 Paolo Carlini PR c++/84605 * parser.c (cp_parser_class_head): Reject TYPE_BEING_DEFINED too. /testsuite 2019-03-04 Paolo Carlini PR c++/84605 * g++.dg/parse/crash69.C: New. From-SVN: r269378 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8c0bfd994eb..69971800099 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-03-04 Paolo Carlini + + PR c++/84605 + * parser.c (cp_parser_class_head): Reject TYPE_BEING_DEFINED too. + 2019-03-04 Jakub Jelinek PR c++/71446 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 580426780ea..155e350d01d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -24021,8 +24021,11 @@ cp_parser_class_head (cp_parser* parser, cp_parser_check_class_key (class_key, type); /* If this type was already complete, and we see another definition, - that's an error. */ - if (type != error_mark_node && COMPLETE_TYPE_P (type)) + that's an error. Likewise if the type is already being defined: + this can happen, eg, when it's defined from within an expression + (c++/84605). */ + if (type != error_mark_node + && (COMPLETE_TYPE_P (type) || TYPE_BEING_DEFINED (type))) { error_at (type_start_token->location, "redefinition of %q#T", type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3186805c9cb..c06d63a17a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-04 Paolo Carlini + + PR c++/84605 + * g++.dg/parse/crash69.C: New. + 2019-03-04 Jakub Jelinek PR c++/71446 diff --git a/gcc/testsuite/g++.dg/parse/crash69.C b/gcc/testsuite/g++.dg/parse/crash69.C new file mode 100644 index 00000000000..a85bbeee392 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash69.C @@ -0,0 +1,11 @@ +// PR c++/84605 + +struct b { + int x(((struct b {}))); // { dg-error "expected|redefinition" } +}; + +struct c { + struct d { + int x(((struct c {}))); // { dg-error "expected|redefinition" } + }; +};