From 741bbaabaffa7db912a775077897ad72611471f3 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 12 Sep 2017 19:45:37 +0000 Subject: [PATCH] re PR c++/70621 (ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64) /cp 2017-09-12 Paolo Carlini PR c++/70621 * decl.c (start_decl): Early return error_mark_node if duplicate_decls returns it; avoid misleading error message. /testsuite 2017-09-12 Paolo Carlini PR c++/70621 * g++.dg/torture/pr70621.C: New. From-SVN: r252040 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 9 +++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr70621.C | 13 +++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr70621.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9e011e9..56ecf72 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-09-12 Paolo Carlini + + PR c++/70621 + * decl.c (start_decl): Early return error_mark_node if duplicate_decls + returns it; avoid misleading error message. + 2017-09-12 Nathan Sidwell Kill CLASSTYPE_SORTED_FIELDS. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6f3a348..6101bdf 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5022,11 +5022,12 @@ start_decl (const cp_declarator *declarator, about this situation, and so we check here. */ if (initialized && DECL_INITIALIZED_IN_CLASS_P (field)) error ("duplicate initialization of %qD", decl); - if (duplicate_decls (decl, field, /*newdecl_is_friend=*/false)) + field = duplicate_decls (decl, field, + /*newdecl_is_friend=*/false); + if (field == error_mark_node) + return error_mark_node; + else if (field) decl = field; - if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr) - && !DECL_DECLARED_CONSTEXPR_P (field)) - error ("%qD declared % outside its class", field); } } else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ad989fd..dc5ae01 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +017-09-12 Paolo Carlini + + PR c++/70621 + * g++.dg/torture/pr70621.C: New. + 2017-09-12 Paul Thomas PR fortran/82173 diff --git a/gcc/testsuite/g++.dg/torture/pr70621.C b/gcc/testsuite/g++.dg/torture/pr70621.C new file mode 100644 index 0000000..63eb928 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr70621.C @@ -0,0 +1,13 @@ +float foo(); + +struct A +{ + static float x; // { dg-message "previous declaration" } +}; + +double A::x = foo(); // { dg-error "conflicting declaration" } + +void bar() +{ + A::x = 0; +} -- 2.7.4