]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/28294 (ICE with invalid use of __builtin_offsetof)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Sat, 15 Jul 2006 09:38:02 +0000 (09:38 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sat, 15 Jul 2006 09:38:02 +0000 (09:38 +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: r115468

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

index 69b83d4efe09667434e04800663e1a157ae47fa6..81d872ecf7aeb6b471b287d8e9f29021132174fe 100644 (file)
@@ -1,3 +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.
+
 2006-07-14  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/28343
index 74c34d85f2a5c43b15d03a427caff3d4d26ce6eb..ab0abf1004c442406002ceec51327d145ee852a1 100644 (file)
@@ -2804,8 +2804,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 919074d932e06bf46f78251f8f31c5e109b948c6..cd7f3b53c027a684c882ea4f54bb9b6892245624 100644 (file)
@@ -1,3 +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.
+
 2006-07-14  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/28343
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;