OSDN Git Service

PR c++/19964
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Oct 2005 10:59:27 +0000 (10:59 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Oct 2005 10:59:27 +0000 (10:59 +0000)
* stor-layout.c (place_field): Set DECL_FIELD_OFFSET and
DECL_FIELD_BIT_OFFSET of FIELD_DECLs, even if they have an invalid
type.
cp:
PR c++/19964
* cp/class.c (walk_subobject_offsets): Don't walk error_mark_node.
testsuite:
PR c++/19964
* g++.dg/parse/crash31.C: New.

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

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/stor-layout.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/crash31.C [new file with mode: 0644]

index 5b300b1..f7ce015 100644 (file)
@@ -1,3 +1,10 @@
+2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/19964
+       * stor-layout.c (place_field): Set DECL_FIELD_OFFSET and
+       DECL_FIELD_BIT_OFFSET of FIELD_DECLs, even if they have an invalid
+       type.
+
 2005-10-12  Richard Guenther  <rguenther@suse.de>
 
        PR c++/23799
@@ -39,6 +46,7 @@
        Only apply the optimization for rounding builtins if the inner
        cast is also an extension.
 
+>>>>>>> 2.10143
 2005-10-11  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR tree-opt/23946
index a544cfa..53a5cb0 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/19964
+       * cp/class.c (walk_subobject_offsets): Don't walk error_mark_node.
+
 2005-10-11  Ian Lance Taylor  <ian@airs.com>
 
        PR c++/8057
index 35e7cb9..3f56652 100644 (file)
@@ -3101,6 +3101,9 @@ walk_subobject_offsets (tree type,
   if (max_offset && INT_CST_LT (max_offset, offset))
     return 0;
 
+  if (type == error_mark_node)
+    return 0;
+  
   if (!TYPE_P (type))
     {
       if (abi_version_at_least (2))
index aec80a3..7b81abf 100644 (file)
@@ -800,9 +800,19 @@ place_field (record_layout_info rli, tree field)
   /* The type of this field.  */
   tree type = TREE_TYPE (field);
 
-  if (TREE_CODE (field) == ERROR_MARK || TREE_CODE (type) == ERROR_MARK)
-      return;
+  gcc_assert (TREE_CODE (field) != ERROR_MARK);
 
+  if (TREE_CODE (type) == ERROR_MARK)
+    {
+      if (TREE_CODE (field) == FIELD_DECL)
+       {
+         DECL_FIELD_OFFSET (field) = size_int (0);
+         DECL_FIELD_BIT_OFFSET (field) = bitsize_int (0);
+       }
+      
+      return;
+    }
+  
   /* If FIELD is static, then treat it like a separate variable, not
      really like a structure field.  If it is a FUNCTION_DECL, it's a
      method.  In both cases, all we do is lay out the decl, and we do
index 2fcbdb7..51b8119 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/19964
+       * g++.dg/parse/crash31.C: New.
+
 2005-10-12  Razya Ladelsky <razya@il.ibm.com>
 
         * g++.dg/ipa/ipa-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/parse/crash31.C b/gcc/testsuite/g++.dg/parse/crash31.C
new file mode 100644 (file)
index 0000000..c3fc679
--- /dev/null
@@ -0,0 +1,9 @@
+struct A
+{ // { dg-error "forward declaration" }
+  A : A; // { dg-error "expected|incomplete" }
+  A : B; // { dg-error "not declared|incomplete" }
+  A : A(); // { dg-error "undefined type|incomplete" }
+  A : B(); // { dg-error "function call|incomplete" }
+  A : A[]; // { dg-error "expected|array reference|incomplete" }
+  A : B[]; // { dg-error "not declared|expected|array reference|incomplete" }
+};