OSDN Git Service

2007-03-28 Simon Martin <simartin@users.sourceforge.net>
authorsimartin <simartin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Mar 2007 21:06:01 +0000 (21:06 +0000)
committersimartin <simartin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Mar 2007 21:06:01 +0000 (21:06 +0000)
PR c++/29077
* decl.c (grokfndecl): Properly setup decl if it is a constructor or a
destructor.

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

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

index a2a0f6e..4f2b061 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-28  Simon Martin  <simartin@users.sourceforge.net>
+
+       PR c++/29077
+       * decl.c (grokfndecl): Properly setup decl if it is a constructor or a
+       destructor.
+
 2007-03-28 Douglas Gregor <doug.gregor@gmail.com>
 
        * parser.c (struct cp_parser): Update comment for
index ce1c54f..0315f01 100644 (file)
@@ -5981,6 +5981,20 @@ grokfndecl (tree ctype,
   if (TYPE_VOLATILE (type))
     TREE_THIS_VOLATILE (decl) = 1;
 
+  /* Setup decl according to sfk.  */
+  switch (sfk)
+    {
+    case sfk_constructor:
+    case sfk_copy_constructor:
+      DECL_CONSTRUCTOR_P (decl) = 1;
+      break;
+    case sfk_destructor:
+      DECL_DESTRUCTOR_P (decl) = 1;
+      break;
+    default:
+      break;
+    }
+
   if (friendp
       && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR)
     {
@@ -6168,12 +6182,7 @@ grokfndecl (tree ctype,
     return decl;
 
   if (ctype != NULL_TREE)
-    {
-      if (sfk == sfk_constructor)
-       DECL_CONSTRUCTOR_P (decl) = 1;
-
-      grokclassfn (ctype, decl, flags);
-    }
+    grokclassfn (ctype, decl, flags);
 
   decl = check_explicit_specialization (orig_declarator, decl,
                                        template_count,
index b3b28b3..9b5244e 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-28  Simon Martin  <simartin@users.sourceforge.net>
+
+       PR c++/29077
+       * g++.dg/parse/constructor3.C: New test.
+
 2007-03-28  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/thin_pointer.ad[sb]: New test.
diff --git a/gcc/testsuite/g++.dg/parse/constructor3.C b/gcc/testsuite/g++.dg/parse/constructor3.C
new file mode 100644 (file)
index 0000000..9a2e978
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR c++/29077 */
+/* { dg-do "compile" } */
+
+class c {
+  c();
+  c(const c&);
+  ~c();
+};
+
+namespace m {
+  c::c() {} /* { dg-error "c::c" } */
+  c::c(const c&) {} /* { dg-error "c::c" } */
+  c::~c() {} /* { dg-error "c::~c" } */
+}