OSDN Git Service

PR c++/12218
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Dec 2003 04:45:53 +0000 (04:45 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Dec 2003 04:45:53 +0000 (04:45 +0000)
* varasm.c (initializer_constant_valid_p): Allow a conversion from
an integral constant to an OFFSET_TYPE.

PR c++/12696
* decl.c (reshape_init): Recover quickly from errors.

PR c++/12218
* g++.dg/init/pm3.C: New test.

PR c++/12696
* g++.dg/init/error1.C: New test.

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

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/error1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/init/pm3.C [new file with mode: 0644]
gcc/varasm.c

index 40a362f..dad08e4 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12218
+       * varasm.c (initializer_constant_valid_p): Allow a conversion from
+       an integral constant to an OFFSET_TYPE.
+
 2003-12-16  Kazu Hirata  <kazu@cs.umass.edu>
 
        PR target/11012
index 3e6d1b2..fd63165 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12696
+       * decl.c (reshape_init): Recover quickly from errors.
+
 2003-12-16  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/9043
@@ -9,6 +14,9 @@
 
 2003-12-16  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/12696
+       * decl.c (reshape_init): Recover quickly from errors.
+
        PR c++/13275
        * lex.c (reswords): Add "__offsetof" and "__offsetof__".
        * parser.c (cp_parser): Add in_offsetof_p.
index c054bfb..5677781 100644 (file)
@@ -4271,8 +4271,11 @@ reshape_init (tree type, tree *initp)
                 empty class shall have the form of an empty
                 initializer-list {}.  */
              if (!brace_enclosed_p)
-               error ("initializer for `%T' must be brace-enclosed",
-                      type);
+               {
+                 error ("initializer for `%T' must be brace-enclosed",
+                        type);
+                 return error_mark_node;
+               }
            }
          else
            {
@@ -4297,6 +4300,8 @@ reshape_init (tree type, tree *initp)
                    break;
 
                  field_init = reshape_init (TREE_TYPE (field), initp);
+                 if (field_init == error_mark_node)
+                   return error_mark_node;
                  TREE_CHAIN (field_init) = CONSTRUCTOR_ELTS (new_init);
                  CONSTRUCTOR_ELTS (new_init) = field_init;
                  /* [dcl.init.aggr] 
@@ -4327,6 +4332,8 @@ reshape_init (tree type, tree *initp)
              tree element_init;
 
              element_init = reshape_init (TREE_TYPE (type), initp);
+             if (element_init == error_mark_node)
+               return error_mark_node;
              TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init);
              CONSTRUCTOR_ELTS (new_init) = element_init;
              if (TREE_PURPOSE (element_init))
index a0aa37f..5f1ecdc 100644 (file)
@@ -1,3 +1,11 @@
+2003-12-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12696
+       * g++.dg/init/error1.C: New test.
+
+       PR c++/12218
+       * g++.dg/init/pm3.C: New test.
+
 2003-12-17  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        PR c/3347
diff --git a/gcc/testsuite/g++.dg/init/error1.C b/gcc/testsuite/g++.dg/init/error1.C
new file mode 100644 (file)
index 0000000..e930fc7
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/12696
+
+struct A {
+  static float b[10]; // { dg-error "" }
+}
+
+float A::b[] = {1,2,3}; // { dg-error "" }
diff --git a/gcc/testsuite/g++.dg/init/pm3.C b/gcc/testsuite/g++.dg/init/pm3.C
new file mode 100644 (file)
index 0000000..980790d
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/12218
+// { dg-do run }
+
+struct C { int i, j; };
+typedef int C::*mPtr;
+extern const mPtr should_be_0 = &C::i;
+extern const mPtr should_be_4 = &C::j;
+
+int main () {
+}
index 5257810..4fecf37 100644 (file)
@@ -3592,7 +3592,8 @@ initializer_constant_valid_p (tree value, tree endtype)
 
       /* Likewise conversions from int to pointers, but also allow
         conversions from 0.  */
-      if (POINTER_TYPE_P (TREE_TYPE (value))
+      if ((POINTER_TYPE_P (TREE_TYPE (value))
+          || TREE_CODE (TREE_TYPE (value)) == OFFSET_TYPE)
          && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
        {
          if (integer_zerop (TREE_OPERAND (value, 0)))