PR c++/85033
* semantics.c (finish_offsetof): Don't allow CONST_DECLs.
* g++.dg/ext/builtin-offsetof2.C: New test.
From-SVN: r258801
+2018-03-23 Marek Polacek <polacek@redhat.com>
+
+ PR c++/85033
+ * semantics.c (finish_offsetof): Don't allow CONST_DECLs.
+
2018-03-23 Alexandre Oliva <aoliva@redhat.com>
PR c++/71251
}
return error_mark_node;
}
+ if (TREE_CODE (expr) == CONST_DECL)
+ {
+ error ("cannot apply %<offsetof%> to an enumerator %qD", expr);
+ return error_mark_node;
+ }
if (REFERENCE_REF_P (expr))
expr = TREE_OPERAND (expr, 0);
if (!complete_type_or_else (TREE_TYPE (TREE_TYPE (object_ptr)), object_ptr))
+2018-03-23 Marek Polacek <polacek@redhat.com>
+
+ PR c++/85033
+ * g++.dg/ext/builtin-offsetof2.C: New test.
+
2018-03-23 Eric Botcazou <ebotcazou@adacore.com>
PR debug/85020
--- /dev/null
+// PR c++/85033
+
+struct S {
+ enum { E };
+};
+
+int b = __builtin_offsetof(S, E); // { dg-error "cannot apply .offsetof. to an enumerator" }