Commit 0a9367cb by Volker Reichelt Committed by Volker Reichelt

re PR c++/28294 (ICE with invalid use of __builtin_offsetof)

	PR c++/28294
	* semantics.c (finish_offsetof): Use TREE_OPERAND for COMPONENT_REFs
	only.

	* g++.dg/ext/offsetof1.C: Add test with function pointer arithmetic.

From-SVN: r115466
parent 6ae9b875
2006-07-15 Volker Reichelt <reichelt@igpm.rwth-aachen.de> 2006-07-15 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/28294
* semantics.c (finish_offsetof): Use TREE_OPERAND for COMPONENT_REFs
only.
PR c++/28387 PR c++/28387
* decl2.c (cplus_decl_attributes): Check for invalid decls. * decl2.c (cplus_decl_attributes): Check for invalid decls.
......
...@@ -2905,8 +2905,9 @@ finish_offsetof (tree expr) ...@@ -2905,8 +2905,9 @@ finish_offsetof (tree expr)
|| TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
|| TREE_CODE (TREE_TYPE (expr)) == UNKNOWN_TYPE) || TREE_CODE (TREE_TYPE (expr)) == UNKNOWN_TYPE)
{ {
error ("cannot apply %<offsetof%> to member function %qD", if (TREE_CODE (expr) == COMPONENT_REF)
TREE_OPERAND (expr, 1)); expr = TREE_OPERAND (expr, 1);
error ("cannot apply %<offsetof%> to member function %qD", expr);
return error_mark_node; return error_mark_node;
} }
return fold_offsetof (expr); return fold_offsetof (expr);
......
2006-07-15 Volker Reichelt <reichelt@igpm.rwth-aachen.de> 2006-07-15 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/28294
* g++.dg/ext/offsetof1.C: Add test with function pointer arithmetic.
PR c++/28387 PR c++/28387
* g++.dg/ext/attrib24.C: New test. * g++.dg/ext/attrib24.C: New test.
...@@ -9,6 +9,7 @@ struct bar { ...@@ -9,6 +9,7 @@ struct bar {
int a = __builtin_offsetof(bar, foo); // { dg-error "static data member" } int a = __builtin_offsetof(bar, foo); // { dg-error "static data member" }
int b = __builtin_offsetof(bar, baz); // { dg-error "member function" } int b = __builtin_offsetof(bar, baz); // { dg-error "member function" }
int b0 = __builtin_offsetof(bar, baz[0]); // { dg-error "function" }
int c = __builtin_offsetof(bar, ~bar); // { dg-error "member function" } int c = __builtin_offsetof(bar, ~bar); // { dg-error "member function" }
typedef int I; 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