OSDN Git Service

PR c++/9823
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 8 Mar 2003 18:47:42 +0000 (18:47 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 8 Mar 2003 18:47:42 +0000 (18:47 +0000)
* cp-tree.h (begin_mem_initializers): Remove.
* parser.c (cp_parser_mem_initializer_list): Inline it here.
Do not call finish_mem_initializers if not in a constructor.
(cp_parser_class_head): Fix typo in error message.
* semantics.c (begin_mem_initializers): Remove.
* testsuite/g++.dg/parser/constructor1.C: New test.

PR c++/9823
* g++.dg/parser/constructor1.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/constructor1.C [new file with mode: 0644]

index 4acff21..53e1b74 100644 (file)
@@ -1,5 +1,13 @@
 2003-03-08  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/9823
+       * cp-tree.h (begin_mem_initializers): Remove.
+       * parser.c (cp_parser_mem_initializer_list): Inline it here.
+       Do not call finish_mem_initializers if not in a constructor.
+       (cp_parser_class_head): Fix typo in error message.
+       * semantics.c (begin_mem_initializers): Remove.
+       * testsuite/g++.dg/parser/constructor1.C: New test.
+
        PR c++/9809
        * call.c (add_function_candidate): Skip builtin fuctions that have
        not yet been declared.
index 3ab95cc..b4eeb76 100644 (file)
@@ -4205,7 +4205,6 @@ extern void expand_body                         (tree);
 extern tree nullify_returns_r                (tree *, int *, void *);
 extern void do_pushlevel                        (scope_kind);
 extern tree do_poplevel                         (void);
-extern void begin_mem_initializers              (void);
 extern void finish_mem_initializers             (tree);
 extern void setup_vtbl_ptr                     (tree, tree);
 extern void clear_out_block                     (void);
index 468ba03..1c83227 100644 (file)
@@ -7189,7 +7189,8 @@ cp_parser_mem_initializer_list (cp_parser* parser)
 
   /* Let the semantic analysis code know that we are starting the
      mem-initializer-list.  */
-  begin_mem_initializers ();
+  if (!DECL_CONSTRUCTOR_P (current_function_decl))
+    error ("only constructors take base initializers");
 
   /* Loop through the list.  */
   while (true)
@@ -7212,7 +7213,8 @@ cp_parser_mem_initializer_list (cp_parser* parser)
     }
 
   /* Perform semantic analysis.  */
-  finish_mem_initializers (mem_initializer_list);
+  if (DECL_CONSTRUCTOR_P (current_function_decl))
+    finish_mem_initializers (mem_initializer_list);
 }
 
 /* Parse a mem-initializer.
@@ -11789,7 +11791,7 @@ cp_parser_class_head (cp_parser* parser,
         class was originally declared, the program is invalid.  */
       if (scope && !is_ancestor (scope, CP_DECL_CONTEXT (type)))
        {
-         error ("declaration of `%D' in  `%D' which does not "
+         error ("declaration of `%D' in `%D' which does not "
                 "enclose `%D'", type, scope, nested_name_specifier);
          return NULL_TREE;
        }
index cf0bec7..a5b7c50 100644 (file)
@@ -1142,15 +1142,6 @@ finish_eh_cleanup (cleanup)
   add_stmt (r);
 }
 
-/* Begin processing a mem-initializer-list.  */
-
-void
-begin_mem_initializers ()
-{
-  if (! DECL_CONSTRUCTOR_P (current_function_decl))
-    error ("only constructors take base initializers");
-}
-
 /* The MEM_INITS is a list of mem-initializers, in reverse of the
    order they were written by the user.  Each node is as for
    emit_mem_initializers.  */
index 0d3d209..8c11f85 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-08  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9823
+       * g++.dg/parser/constructor1.C: New test.
+
 2003-03-08  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * gcc.c-torture/execute/20020720-1.x: Add xfail for cris-*-*.
diff --git a/gcc/testsuite/g++.dg/parse/constructor1.C b/gcc/testsuite/g++.dg/parse/constructor1.C
new file mode 100644 (file)
index 0000000..3011862
--- /dev/null
@@ -0,0 +1,4 @@
+ACE_Process_Descriptor::ACE_Process_Descriptor () : // { dg-error "" }
+  process_ (0)
+{
+}