OSDN Git Service

PR c++/46538
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 20 Nov 2010 08:15:33 +0000 (08:15 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 20 Nov 2010 08:15:33 +0000 (08:15 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166974 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/error34.C [new file with mode: 0644]

index e3d97d2..8310ca6 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 55e0d6a..787608c 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 1a54308..9a00252 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 }