re PR c++/27601 (ICE (in fold_offsetof_1, at c-common.c:5998) on strange offsetof)

PR c++/27601
	* semantics.c (finish_offsetof): Handle pseudo-destructors.

	* g++.dg/ext/offsetof1.C: Add test for pseudo-destructors.

From-SVN: r114588
This commit is contained in:
Volker Reichelt 2006-06-12 22:56:07 +00:00 committed by Volker Reichelt
parent dfa9dde4e0
commit 4c65a5340d
4 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,8 @@
2006-06-12 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27601
* semantics.c (finish_offsetof): Handle pseudo-destructors.
PR c++/27933
* name-lookup.c (lookup_qualified_name): Always return error_mark_node
if lookup fails.

View File

@ -2887,6 +2887,12 @@ finish_typeof (tree expr)
tree
finish_offsetof (tree expr)
{
if (TREE_CODE (expr) == PSEUDO_DTOR_EXPR)
{
error ("cannot apply %<offsetof%> to destructor %<~%T%>",
TREE_OPERAND (expr, 2));
return error_mark_node;
}
if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
|| TREE_CODE (TREE_TYPE (expr)) == UNKNOWN_TYPE)

View File

@ -1,3 +1,8 @@
2006-06-12 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27601
* g++.dg/ext/offsetof1.C: Add test for pseudo-destructors.
2006-06-12 Mark Mitchell <mark@codesourcery.com>
Kazu Hirata <kazu@codesourcery.com>

View File

@ -10,3 +10,9 @@ struct bar {
int a = __builtin_offsetof(bar, foo); // { dg-error "static data member" }
int b = __builtin_offsetof(bar, baz); // { dg-error "member function" }
int c = __builtin_offsetof(bar, ~bar); // { dg-error "member function" }
typedef int I;
enum E { };
int d = __builtin_offsetof(I, ~I); // { dg-error "destructor" }
int e = __builtin_offsetof(E, ~E); // { dg-error "destructor" }