From 8304847453e7d901839ae9f266394d57a86b6da4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 20 Nov 2010 09:15:33 +0100 Subject: [PATCH] re PR c++/46538 (ICE: SIGSEGV in cp_make_fname_decl (decl.c:3690) on invalid code when using __PRETTY_FUNCTION__) PR c++/46538 * decl.c (cp_make_fname_decl): Return error_mark_node if current_binding_level has already sk_function_parms kind. * g++.dg/other/error34.C: New test. From-SVN: r166974 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 2 ++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/other/error34.C | 6 ++++++ 4 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/g++.dg/other/error34.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e3d97d2..8310ca6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-11-20 Jakub Jelinek + PR c++/46538 + * decl.c (cp_make_fname_decl): Return error_mark_node if + current_binding_level has already sk_function_parms kind. + PR c++/46526 * semantics.c (cxx_eval_call_expression): Unshare the result. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 55e0d6a..787608c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3687,6 +3687,8 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep) if (current_function_decl) { struct cp_binding_level *b = current_binding_level; + if (b->kind == sk_function_parms) + return error_mark_node; while (b->level_chain->kind != sk_function_parms) b = b->level_chain; pushdecl_with_scope (decl, b, /*is_friend=*/false); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1a54308..9a00252 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-11-20 Jakub Jelinek + PR c++/46538 + * g++.dg/other/error34.C: New test. + PR c++/46526 * g++.dg/cpp0x/constexpr-base3.C: New test. diff --git a/gcc/testsuite/g++.dg/other/error34.C b/gcc/testsuite/g++.dg/other/error34.C new file mode 100644 index 0000000..10a782d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error34.C @@ -0,0 +1,6 @@ +// PR c++/46538 +// { dg-do compile } +// { dg-options "" } + +S () : str(__PRETTY_FUNCTION__) {} // { dg-error "forbids declaration" } +// { dg-error "only constructors" "" { target *-*-* } 5 } -- 2.7.4