]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/27601 (ICE (in fold_offsetof_1, at c-common.c:5998) on strange offsetof)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Sun, 4 Jun 2006 23:51:52 +0000 (23:51 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sun, 4 Jun 2006 23:51:52 +0000 (23:51 +0000)
PR c++/27601
* c-common.c (fold_offsetof_1): Handle static members.

* g++.dg/ext/offsetof1.C: New test.

From-SVN: r114371

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/offsetof1.C [new file with mode: 0644]

index aa946ca0a823544375408f0cc06c25c19214e701..ae6f258d2c46fa2266511a00529a0ee8e279984e 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-04  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/27601
+       * c-common.c (fold_offsetof_1): Handle static members.
+
 2006-05-30  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c/27718
index 04660ed482b4b8c5c6954b03b66ad7a51eccb40b..53e18c553f5b9dbffbf7392cf3be1b6c347f94c9 100644 (file)
@@ -5730,6 +5730,10 @@ fold_offsetof_1 (tree expr)
     case ERROR_MARK:
       return expr;
 
+    case VAR_DECL:
+      error ("cannot apply %<offsetof%> to static data member %qD", expr);
+      return error_mark_node;
+
     case INDIRECT_REF:
       return size_zero_node;
 
index 8dc0d9740b50883666a39a4044e84edde045b8f8..bbcee3a36e1f52731b6a43f31211cd700c9886d9 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-04  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/27601
+       * g++.dg/ext/offsetof1.C: New test.
+
 2006-05-30  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c/27718
diff --git a/gcc/testsuite/g++.dg/ext/offsetof1.C b/gcc/testsuite/g++.dg/ext/offsetof1.C
new file mode 100644 (file)
index 0000000..5d6552f
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/27601
+// Origin: Patrik Hägglund  <patrik.hagglund@bredband.net>
+// { dg-do compile }
+
+struct bar {
+  static int foo;
+};
+
+int a = __builtin_offsetof(bar, foo);  // { dg-error "static data member" }