From dc5554292fd779dbbb13e37bab33c469704b9ad6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 29 Jan 2008 00:50:24 -0500 Subject: [PATCH] re PR c++/35007 (Firefox fails to build with affentry.cpp:94: error: ISO C++ forbids subscripting non-lvalue array) PR c++/35007 * class.c (build_base_path): Fix !want_pointer case. From-SVN: r131931 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/class.c | 7 ++++++- gcc/testsuite/g++.dg/inherit/sizeof1.C | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/inherit/sizeof1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 118d25d8f56..7b5da5349cd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2008-01-28 Jason Merrill + + PR c++/35007 + * class.c (build_base_path): Fix !want_pointer case. + 2008-01-27 Jason Merrill PR c++/27177 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0ce4ba49990..9f7d986676c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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 index 00000000000..06d5c9993d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/sizeof1.C @@ -0,0 +1,17 @@ +// PR c++/35007 + +struct AffEntry +{ + union { + char base[256]; + } conds; +}; + +struct PfxEntry +: public AffEntry +{ + PfxEntry() + { + sizeof(conds.base[0]); + } +}; -- 2.30.2