Commit b01556f7 by Marek Polacek Committed by Marek Polacek

re PR c++/85033 (internal compiler error: in fold_offsetof_1, at c-family/c-common.c:6269)

	PR c++/85033
	* semantics.c (finish_offsetof): Don't allow CONST_DECLs.

	* g++.dg/ext/builtin-offsetof2.C: New test.

From-SVN: r258801
parent f300628b
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> 2018-03-23 Alexandre Oliva <aoliva@redhat.com>
PR c++/71251 PR c++/71251
......
...@@ -4072,6 +4072,11 @@ finish_offsetof (tree object_ptr, tree expr, location_t loc) ...@@ -4072,6 +4072,11 @@ finish_offsetof (tree object_ptr, tree expr, location_t loc)
} }
return error_mark_node; 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)) if (REFERENCE_REF_P (expr))
expr = TREE_OPERAND (expr, 0); expr = TREE_OPERAND (expr, 0);
if (!complete_type_or_else (TREE_TYPE (TREE_TYPE (object_ptr)), object_ptr)) 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> 2018-03-23 Eric Botcazou <ebotcazou@adacore.com>
PR debug/85020 PR debug/85020
......
// PR c++/85033
struct S {
enum { E };
};
int b = __builtin_offsetof(S, E); // { dg-error "cannot apply .offsetof. to an enumerator" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment