OSDN Git Service

PR c++/28506
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Oct 2006 08:38:43 +0000 (08:38 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Oct 2006 08:38:43 +0000 (08:38 +0000)
* parser.c (function_declarator_p): New function.
(cp_parser_init_declarator): Use it.
(cp_parser_member_declaration): Likewise.
PR c++/28506
* g++.dg/parse/pure1.C: New test.

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

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

index 18958d4..b1df987 100644 (file)
@@ -1,3 +1,10 @@
+2006-10-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/28506
+       * parser.c (function_declarator_p): New function.
+       (cp_parser_init_declarator): Use it.
+       (cp_parser_member_declaration): Likewise.
+
 2006-10-12  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/29318
index 41fe858..cb357cf 100644 (file)
@@ -965,6 +965,24 @@ make_parameter_declarator (cp_decl_specifier_seq *decl_specifiers,
   return parameter;
 }
 
+/* Returns true iff DECLARATOR  is a declaration for a function.  */
+
+static bool
+function_declarator_p (const cp_declarator *declarator)
+{
+  while (declarator)
+    {
+      if (declarator->kind == cdk_function
+         && declarator->declarator->kind == cdk_id)
+       return true;
+      if (declarator->kind == cdk_id
+         || declarator->kind == cdk_error)
+       return false;
+      declarator = declarator->declarator;
+    }
+  return false;
+}
 /* The parser.  */
 
 /* Overview
@@ -11157,8 +11175,7 @@ cp_parser_init_declarator (cp_parser* parser,
   is_non_constant_init = true;
   if (is_initialized)
     {
-      if (declarator->kind == cdk_function
-         && declarator->declarator->kind == cdk_id
+      if (function_declarator_p (declarator)
          && initialization_kind == CPP_EQ)
        initializer = cp_parser_pure_specifier (parser);
       else
@@ -13825,8 +13842,7 @@ cp_parser_member_declaration (cp_parser* parser)
                     for a pure-specifier; otherwise, we look for a
                     constant-initializer.  When we call `grokfield', it will
                     perform more stringent semantics checks.  */
-                 if (declarator->kind == cdk_function
-                     && declarator->declarator->kind == cdk_id)
+                 if (function_declarator_p (declarator))
                    initializer = cp_parser_pure_specifier (parser);
                  else
                    /* Parse the initializer.  */
index 6741909..3a48c5d 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/28506
+       * g++.dg/parse/pure1.C: New test.
+
 2006-10-13  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR fortran/21435
diff --git a/gcc/testsuite/g++.dg/parse/pure1.C b/gcc/testsuite/g++.dg/parse/pure1.C
new file mode 100644 (file)
index 0000000..2b6f28b
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/28506
+
+struct A
+{
+  virtual void* foo() = 1; // { dg-error "pure" }
+};
+
+struct B
+{
+  void operator()()() = 1; // { dg-error "pure|function|initializer" }
+};