commit 92f52fccaaf25b5791c0f8bff930fe75d25bd90b
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jun 30 23:05:49 2011 -0400
PR c++/49085
* semantics.c (finish_offsetof): Complain about incomplete type.
@@ -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);
}
new file mode 100644
@@ -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;