]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/46538 (ICE: SIGSEGV in cp_make_fname_decl (decl.c:3690) on invalid code...
authorJakub Jelinek <jakub@redhat.com>
Sat, 20 Nov 2010 08:15:33 +0000 (09:15 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 20 Nov 2010 08:15:33 +0000 (09:15 +0100)
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
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/error34.C [new file with mode: 0644]

index e3d97d22d5597ab03c27d0e8075772d6d5edb740..8310ca6e032feb519a6ab1fc642f1b424166dc25 100644 (file)
@@ -1,5 +1,9 @@
 2010-11-20  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
 
index 55e0d6a74f5d88317c818a59582713c657c8e3b4..787608c891a1f5ebcb607749ef5c0dbf25c88404 100644 (file)
@@ -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);
index 1a543089601a4e2a6c47878aca7bbd8f38b03516..9a002528bb19c8fecc9e6cd7d603c6a404e99fd4 100644 (file)
@@ -1,5 +1,8 @@
 2010-11-20  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..10a782d
--- /dev/null
@@ -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 }