]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/35321 (ICE with invalid use of __builtin_offsetof)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 27 Aug 2008 17:08:40 +0000 (17:08 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 27 Aug 2008 17:08:40 +0000 (17:08 +0000)
2008-08-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/35321
* c-common.c (fold_offsetof_1): Handle TARGET_EXPR like CALL_EXPR.

/testsuite
2008-08-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/35321
* g++.dg/parse/offsetof8.C: New.

From-SVN: r139628

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

index d89d63e6bc4a2ba6c0b1e52fcb5f330baa319aff..4b237afb5ec51848d55fd090f29a7bc065d9f0cb 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/35321
+       * c-common.c (fold_offsetof_1): Handle TARGET_EXPR like CALL_EXPR.
+
 2008-08-27  Paul Brook  <paul@codesourcery.com>
 
        * config.gcc: Loosen checks for arm uclinux eabi targets.
index 811092e36c2885d7e07c662759673b7e3bf2c4a2..d06c96940f41cccb51801951a58426f22468e1a5 100644 (file)
@@ -7685,6 +7685,7 @@ fold_offsetof_1 (tree expr, tree stop_ref)
       return error_mark_node;
 
     case CALL_EXPR:
+    case TARGET_EXPR:
       error ("cannot apply %<offsetof%> when %<operator[]%> is overloaded");
       return error_mark_node;
 
index 42d12a230225b7cc26b324ddd3b8e68b80ca16eb..fb2a21a5f06484e8e2af995b17a8ae89e2d0990d 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/35321
+       * g++.dg/parse/offsetof8.C: New.
+
 2008-08-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        PR c++/17880
diff --git a/gcc/testsuite/g++.dg/parse/offsetof8.C b/gcc/testsuite/g++.dg/parse/offsetof8.C
new file mode 100644 (file)
index 0000000..9add91e
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/35321
+
+struct A
+{
+  A operator[] (int);
+};
+
+struct B
+{
+  A a;
+};
+
+void foo()
+{
+  __builtin_offsetof(B, a[0]); /* { dg-error "error: cannot apply 'offsetof' when 'operator\\\[\\\]' is overloaded" } */
+}