Message ID | 20180305144735.GT16833@redhat.com |
---|---|
State | New |
Headers | show |
Series | C++ PATCH for c++/84707, ICE with nested anonymous namespace | expand |
On 03/05/2018 09:47 AM, Marek Polacek wrote: > Since Nathan's r253489 we seem to not use anon_identifier anymore; rather, the > DECL_NAME is simply NULL. This crashed in duplicate_decls on this invalid code > because UDLIT_OPER_P was blithely used on a possibly null tree. Other spots in > this function check this, too. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? OK. > > 2018-03-05 Marek Polacek <polacek@redhat.com> > > PR c++/84707 > * decl.c (duplicate_decls): Check DECL_NAME before accessing > UDLIT_OPER_P. > > * g++.dg/cpp0x/inline-ns10.C: New test. >
diff --git gcc/cp/decl.c gcc/cp/decl.c index 1866e8f3574..b2e19a6549d 100644 --- gcc/cp/decl.c +++ 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 gcc/testsuite/g++.dg/cpp0x/inline-ns10.C gcc/testsuite/g++.dg/cpp0x/inline-ns10.C index e69de29bb2d..3ab425f7be4 100644 --- gcc/testsuite/g++.dg/cpp0x/inline-ns10.C +++ 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" }