This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/4094: LHS conditional in assignment in gcc/cp/decl.c



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]