PR c++/85061
* c-common.c (fold_offsetof_1) <case COMPOUND_EXPR>: Assert that
get_base_address of the second operand is a VAR_P, rather than the
operand itself, and use gcc_checking_assert instead of gcc_assert.
* g++.dg/ext/builtin-offsetof3.C: New test.
From-SVN: r258902
+2018-03-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/85061
+ * c-common.c (fold_offsetof_1) <case COMPOUND_EXPR>: Assert that
+ get_base_address of the second operand is a VAR_P, rather than the
+ operand itself, and use gcc_checking_assert instead of gcc_assert.
+
2018-03-23 Marek Polacek <polacek@redhat.com>
PR c++/85045
case COMPOUND_EXPR:
/* Handle static members of volatile structs. */
t = TREE_OPERAND (expr, 1);
- gcc_assert (VAR_P (t));
+ gcc_checking_assert (VAR_P (get_base_address (t)));
return fold_offsetof_1 (t);
default:
2018-03-27 Jakub Jelinek <jakub@redhat.com>
+ PR c++/85061
+ * g++.dg/ext/builtin-offsetof3.C: New test.
+
PR c++/85076
* g++.dg/cpp1y/pr85076.C: New test.
--- /dev/null
+// PR c++/85061
+// { dg-do compile }
+
+struct B { int a, b; };
+struct A
+{
+ static int x[2];
+ static int y;
+ static B z;
+};
+
+int i = __builtin_offsetof (volatile A, x[0]); // { dg-error "cannot apply 'offsetof' to static data member 'A::x'" }
+int j = __builtin_offsetof (volatile A, y); // { dg-error "cannot apply 'offsetof' to static data member 'A::y'" }
+int k = __builtin_offsetof (volatile A, z.a); // { dg-error "cannot apply 'offsetof' to a non constant address" }