]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/49085 (Crash with SIGSEGV during compilation.)
authorJason Merrill <jason@redhat.com>
Fri, 1 Jul 2011 13:36:17 +0000 (09:36 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 1 Jul 2011 13:36:17 +0000 (09:36 -0400)
PR c++/49085
* semantics.c (finish_offsetof): Complain about incomplete type.

From-SVN: r175758

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/offsetof2.C [new file with mode: 0644]

index cc950786d9b460de944c966877743b433bfe3224..842d049b2a463cb4303984b8b8aeb809f1c459a1 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49085
+       * semantics.c (finish_offsetof): Complain about incomplete type.
+
 2011-06-30  Jason Merrill  <jason@redhat.com>
 
        PR c++/49387
index ad68a012d17bede5e4d1ee773352ac0c9b077ae3..a704aa3182a5dd9eadf8111fd25c667927e49291 100644 (file)
@@ -3422,6 +3422,12 @@ finish_offsetof (tree expr)
     }
   if (REFERENCE_REF_P (expr))
     expr = TREE_OPERAND (expr, 0);
+  if (TREE_CODE (expr) == COMPONENT_REF)
+    {
+      tree object = TREE_OPERAND (expr, 0);
+      if (!complete_type_or_else (TREE_TYPE (object), object))
+       return error_mark_node;
+    }
   return fold_offsetof (expr, NULL_TREE);
 }
 
index 857ed564f8a5047473d320ff6a26a1b3518ab856..8f2053a84fd2546a36b416c722efcd8ae3014e8d 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49085
+       * g++.dg/template/offsetof2.C: New.
+
 2011-07-01  Kai Tietz  <ktietz@redhat.com>
 
         * gcc.dg/tree-ssa/bitwise-sink.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/offsetof2.C b/gcc/testsuite/g++.dg/template/offsetof2.C
new file mode 100644 (file)
index 0000000..da888f7
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/49085
+
+template <class T>
+struct A                       // { dg-error "declaration" }
+{
+  int i, j;
+  int ar[__builtin_offsetof(A,j)]; // { dg-error "incomplete type" }
+};
+
+A<int> a;