aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>2006-07-15 09:29:32 +0000
committerVolker Reichelt <reichelt@gcc.gnu.org>2006-07-15 09:29:32 +0000
commit0a9367cbdbdc9e5302e7ac39b00c26e698c4100d (patch)
treec2296541e245a9ff4ccd83c21f2f887c4b0714c1 /gcc
parent6ae9b8759e83dcfba6176c397aa703acb48d1f8b (diff)
downloadgcc-0a9367cbdbdc9e5302e7ac39b00c26e698c4100d.zip
gcc-0a9367cbdbdc9e5302e7ac39b00c26e698c4100d.tar.gz
gcc-0a9367cbdbdc9e5302e7ac39b00c26e698c4100d.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/semantics.c5
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/ext/offsetof1.C1
4 files changed, 11 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4b35a3d..fe5d0c7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
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
* decl2.c (cplus_decl_attributes): Check for invalid decls.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 3d5957a..951f9f4 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2905,8 +2905,9 @@ finish_offsetof (tree expr)
|| TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
|| TREE_CODE (TREE_TYPE (expr)) == UNKNOWN_TYPE)
{
- error ("cannot apply %<offsetof%> to member function %qD",
- TREE_OPERAND (expr, 1));
+ if (TREE_CODE (expr) == COMPONENT_REF)
+ expr = TREE_OPERAND (expr, 1);
+ error ("cannot apply %<offsetof%> to member function %qD", expr);
return error_mark_node;
}
return fold_offsetof (expr);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d9edf48..6a2a4b5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
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
* g++.dg/ext/attrib24.C: New test.
diff --git a/gcc/testsuite/g++.dg/ext/offsetof1.C b/gcc/testsuite/g++.dg/ext/offsetof1.C
index e59442d..123a9e3 100644
--- a/gcc/testsuite/g++.dg/ext/offsetof1.C
+++ b/gcc/testsuite/g++.dg/ext/offsetof1.C
@@ -9,6 +9,7 @@ struct bar {
int a = __builtin_offsetof(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 c = __builtin_offsetof(bar, ~bar); // { dg-error "member function" }
typedef int I;