@@ -1962,6 +1962,12 @@ static struct expression *evaluate_offset(struct expression *expr, unsigned long
* we ever take the address of this member dereference..
*/
add->ctype = &lazy_ptr_ctype;
+ /*
+ * The resulting address of a member access through an address
+ * constant is an address constant again [6.6(9)].
+ */
+ add->flags = expr->flags;
+
return add;
}
new file mode 100644
@@ -0,0 +1,26 @@
+struct A {
+ int a;
+ int b[2];
+};
+
+struct B {
+ int c;
+ struct A d;
+};
+
+static struct B a= {1, {1, {1, 1}}};
+
+static int *b = &a.d.a; // OK
+static int *c = &(&a.d)->a; // OK
+static int *d = a.d.b; // OK
+static int *e = (&a.d)->b; // OK
+static int *f = &a.d.b[1]; // OK
+static int *g = &(&a.d)->b[1]; // OK
+
+/*
+ * check-name: address of static object's member constness verification.
+ * check-command: sparse -Wconstexpr-not-const $file
+ *
+ * check-error-start
+ * check-error-end
+ */