Commit 1916c916 by Volker Reichelt Committed by Volker Reichelt

re PR c++/30852 (Trouble with __builtin_offsetof and volatile)

	PR c++/30852
	* c-common.c (fold_offsetof_1): Handle COMPOUND_EXPR.

	* semantics.c (finish_offsetof): Handle COMPOUND_EXPR.

	* g++.dg/ext/offsetof1.C: Add cases with volatile.

From-SVN: r122686
parent cc891727
2007-03-08 Volker Reichelt <reichelt@netcologne.de>
PR c++/30852
* c-common.c (fold_offsetof_1): Handle COMPOUND_EXPR.
2007-03-08 Alexandre Oliva <aoliva@redhat.com>
* c-decl.c (grokdeclarator): Disable warnings for anonymous
......
......@@ -6443,6 +6443,12 @@ fold_offsetof_1 (tree expr, tree stop_ref)
off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t);
break;
case COMPOUND_EXPR:
/* Handle static members of volatile structs. */
t = TREE_OPERAND (expr, 1);
gcc_assert (TREE_CODE (t) == VAR_DECL);
return fold_offsetof_1 (t, stop_ref);
default:
gcc_unreachable ();
}
......
2007-03-08 Volker Reichelt <reichelt@netcologne.de>
PR c++/30852
* semantics.c (finish_offsetof): Handle COMPOUND_EXPR.
PR c++/30534
* pt.c (any_template_arguments_need_structural_equality_p):
Robustify.
......
......@@ -2933,7 +2933,8 @@ finish_offsetof (tree expr)
|| TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
|| TREE_CODE (TREE_TYPE (expr)) == UNKNOWN_TYPE)
{
if (TREE_CODE (expr) == COMPONENT_REF)
if (TREE_CODE (expr) == COMPONENT_REF
|| TREE_CODE (expr) == COMPOUND_EXPR)
expr = TREE_OPERAND (expr, 1);
error ("cannot apply %<offsetof%> to member function %qD", expr);
return error_mark_node;
......
2007-03-08 Volker Reichelt <reichelt@netcologne.de>
PR c++/30852
* g++.dg/ext/offsetof1.C: Add cases with volatile.
PR c++/30534
* g++.dg/template/arg5.C: New test.
......@@ -8,8 +8,10 @@ struct bar {
};
int a = __builtin_offsetof(bar, foo); // { dg-error "static data member" }
int av = __builtin_offsetof(volatile bar, foo); // { dg-error "static data member" }
int b = __builtin_offsetof(bar, baz); // { dg-error "member function" }
int b0 = __builtin_offsetof(bar, baz[0]); // { dg-error "function" }
int bv0 = __builtin_offsetof(volatile bar, baz[0]); // { dg-error "function" }
int c = __builtin_offsetof(bar, ~bar); // { dg-error "member function" }
typedef int I;
......
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