From a2460abb82e2fd3c45edf5e9f4ff61151ef8d815 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 5 Mar 2018 16:15:35 +0000 Subject: [PATCH] re PR c++/84707 (internal compiler error: Segmentation fault (tree_check()/duplicate_decls())) PR c++/84707 * decl.c (duplicate_decls): Check DECL_NAME before accessing UDLIT_OPER_P. * g++.dg/cpp0x/inline-ns10.C: New test. From-SVN: r258255 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/inline-ns10.C | 8 ++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/inline-ns10.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6c37dc3eabb..001cb6a559a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-05 Marek Polacek + + PR c++/84707 + * decl.c (duplicate_decls): Check DECL_NAME before accessing + UDLIT_OPER_P. + 2018-03-05 Nathan Sidwell PR c++/84694 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1866e8f3574..b2e19a6549d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1410,7 +1410,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) || TREE_TYPE (olddecl) == error_mark_node) return error_mark_node; - if (UDLIT_OPER_P (DECL_NAME (newdecl)) + if (DECL_NAME (newdecl) + && DECL_NAME (olddecl) + && UDLIT_OPER_P (DECL_NAME (newdecl)) && UDLIT_OPER_P (DECL_NAME (olddecl))) { if (TREE_CODE (newdecl) == TEMPLATE_DECL diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 934339d97f7..a1f72cb705b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-05 Marek Polacek + + PR c++/84707 + * g++.dg/cpp0x/inline-ns10.C: New test. + 2018-03-05 Nathan Sidwell PR c++/84694 diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns10.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns10.C new file mode 100644 index 00000000000..3ab425f7be4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns10.C @@ -0,0 +1,8 @@ +// PR c++/84707 +// { dg-do compile { target c++11 } } + +inline namespace { + namespace {} +} + +namespace {} // { dg-error "conflicts" } -- 2.30.2