re PR c++/28294 (ICE with invalid use of __builtin_offsetof)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Sat, 15 Jul 2006 09:29:32 +0000 (09:29 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sat, 15 Jul 2006 09:29:32 +0000 (09:29 +0000)
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

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/offsetof1.C

index 4b35a3d37d4655a35794f59bbb4e3f9cda8f1e78..fe5d0c709c233b274d996a5eb3b7b43d676b527c 100644 (file)
@@ -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.
 
index 3d5957aa6fb8ed4397e0f1bd8564cc12bcc1630f..951f9f4bd590b412ed86290f0160b029b77f93b4 100644 (file)
@@ -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);
index d9edf48b3be203c4c5b5cea4ee79e652995dbd97..6a2a4b5c9ba55fa47c1df4f62f86736c03daff4c 100644 (file)
@@ -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.
 
index e59442de4edd6a738f9e005bc39ec3bffa1ace50..123a9e3efeb45f0c5c2089dbc834ecc1faf90d31 100644 (file)
@@ -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;