re PR c++/35007 (Firefox fails to build with affentry.cpp:94: error: ISO C++ forbids...
authorJason Merrill <jason@redhat.com>
Tue, 29 Jan 2008 05:50:24 +0000 (00:50 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 29 Jan 2008 05:50:24 +0000 (00:50 -0500)
        PR c++/35007
        * class.c (build_base_path): Fix !want_pointer case.

From-SVN: r131931

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/g++.dg/inherit/sizeof1.C [new file with mode: 0644]

index 118d25d8f56de5670254a6c3475fa963d9ea630c..7b5da5349cd44e29c1473054343154fb5a255798 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-28  Jason Merrill  <jason@redhat.com>
+
+       PR c++/35007
+       * class.c (build_base_path): Fix !want_pointer case.
+
 2008-01-27  Jason Merrill  <jason@redhat.com>
 
        PR c++/27177
index 0ce4ba499905200716eb0d66730c5558311633bf..9f7d986676cc212229f3580448b42e791b0864c9 100644 (file)
@@ -296,7 +296,12 @@ build_base_path (enum tree_code code,
   /* Don't bother with the calculations inside sizeof; they'll ICE if the
      source type is incomplete and the pointer value doesn't matter.  */
   if (skip_evaluation)
-    return build_nop (build_pointer_type (target_type), expr);
+    {
+      expr = build_nop (build_pointer_type (target_type), expr);
+      if (!want_pointer)
+       expr = build_indirect_ref (expr, NULL);
+      return expr;
+    }
 
   /* Do we need to check for a null pointer?  */
   if (want_pointer && !nonnull)
diff --git a/gcc/testsuite/g++.dg/inherit/sizeof1.C b/gcc/testsuite/g++.dg/inherit/sizeof1.C
new file mode 100644 (file)
index 0000000..06d5c99
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/35007
+
+struct AffEntry
+{
+  union {
+    char base[256];
+  } conds;
+};
+
+struct PfxEntry
+: public AffEntry
+{
+  PfxEntry()
+  {
+    sizeof(conds.base[0]);
+  }
+};