re PR c++/23266 (ICE on pure specifier for static method)
authorVolker Reichelt <reichelt@gcc.gnu.org>
Thu, 11 Aug 2005 22:46:29 +0000 (22:46 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Thu, 11 Aug 2005 22:46:29 +0000 (22:46 +0000)
PR c++/23266
* decl2.c (grokfield): Check that method is not static before
marking it as pure.

PR c++/23266
* g++.dg/inherit/pure1.C: New test.

* ChangeLog: Fix typos.

From-SVN: r103006

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

index e9048213b06872fb7e6a1f6ba9ff85cb8e42b6e5..fce855a3cd198e80e2bca1c99427632735355e52 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-11  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23266
+       * decl2.c (grokfield): Check that method is not static before
+       marking it as pure.
+
 2005-08-11  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/23219
index e7db5525961ce08b4a95eeb62afca64ac469d85f..b08bac86d752e9e5ad922f4231fdfa97b7d5c1a3 100644 (file)
@@ -896,9 +896,17 @@ grokfield (const cp_declarator *declarator,
        {
          /* Initializers for functions are rejected early in the parser.
             If we get here, it must be a pure specifier for a method.  */
-         gcc_assert (TREE_CODE (TREE_TYPE (value)) == METHOD_TYPE);
-         gcc_assert (error_operand_p (init) || integer_zerop (init));
-         DECL_PURE_VIRTUAL_P (value) = 1;
+         if (TREE_CODE (TREE_TYPE (value)) == METHOD_TYPE)
+           {
+             gcc_assert (error_operand_p (init) || integer_zerop (init));
+             DECL_PURE_VIRTUAL_P (value) = 1;
+           }
+         else
+           {
+             gcc_assert (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE);
+             error ("initializer specified for static member function %qD",
+                    value);
+           }
        }
       else if (pedantic && TREE_CODE (value) != VAR_DECL)
        /* Already complained in grokdeclarator.  */
index 40e97e69957627370ccb1cd7b04e6b379ecc96d5..4c3652541a0fc27b5e728114a3e6ca071abeedbb 100644 (file)
@@ -1,4 +1,11 @@
-2005-09-11  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+2005-08-11  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23266
+       * g++.dg/inherit/pure1.C: New test.
+
+       * ChangeLog: Fix typos.
+
+2005-08-11  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
            Steven Bosscher  <stevenb@suse.de>
 
        * gfortran.dg/runtime_warning_1.f90: New test.
@@ -13,7 +20,7 @@
        PR target/23289
        * gcc.target/i386/tailcall-1.c: New testcase.
 
-2005-08-10  James A. Morrison  <phython@gc.gnu.org>
+2005-08-10  James A. Morrison  <phython@gcc.gnu.org>
 
        * gcc.dg/vect/vect-67.c: Un-xfail.
 
diff --git a/gcc/testsuite/g++.dg/inherit/pure1.C b/gcc/testsuite/g++.dg/inherit/pure1.C
new file mode 100644 (file)
index 0000000..ddd3cb3
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/23266
+// Origin: Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+// { dg-do compile }
+
+void foo0() = 0;                   // { dg-error "like a variable" }
+virtual void foo1() = 0;           // { dg-error "outside class|variable" }
+
+struct A
+{
+  void foo2() = 0;                 // { dg-error "non-virtual" }
+  static void foo3() = 0;          // { dg-error "static member" }
+  virtual static void foo4() = 0;  // { dg-error "both virtual and static" }
+  virtual void foo5() = 0;         // { dg-error "base class" }
+};
+
+struct B : A
+{
+  static void foo5() = 0;          // { dg-error "static member|declared" }
+};