This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/4094: LHS conditional in assignment in gcc/cp/decl.c
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/4094: LHS conditional in assignment in gcc/cp/decl.c
- From: rkl at connect dot org dot uk
- Date: 23 Aug 2001 14:23:28 -0000
- Reply-To: rkl at connect dot org dot uk
>Number: 4094
>Category: c++
>Synopsis: LHS conditional in assignment in gcc/cp/decl.c
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Thu Aug 23 07:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: rkl@connect.org.uk
>Release: 3.0.1
>Organization:
>Environment:
HP-UX 11.00, HP ANSI C - other strict K&R/ANSI C compilers
may comaplain too.
>Description:
With HP's ANSI C in HP-UX 11.00, you're not allowed this
construct:
(a?b:c) = 0;
In other words, conditional LHS assignments are prohibited.
Unfortunately, gcc/cp/decl.c is scattered throughout with
them, all relating to the current_binding_level macro,
which appears on the LHS of an assignment about a dozen
times.
>How-To-Repeat:
Compile 3.0.1 with a strict K&R or ANSI C compiler - I used
HP's ANSI C in HP-UX 11.00 for this.
>Fix:
I created a new macro just below the #define current_binding_level line:
#define assign_current_binding_level(rhs) \
if (cfun && cp_function_chain->bindings) \
cp_function_chain->bindings=rhs; \
else scope_chain->bindings=rhs
I then found every occurrence of current_binding_level on
the LHS of an assignment and replaced it with a call
to the new macro instead. For example:
Line 528 was:
current_binding_level = newlevel;
and is now:
assign_current_binding_level(newlevel);
>Release-Note:
>Audit-Trail:
>Unformatted: