public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* skip_evaluation
@ 2009-06-10  0:59 Ian Lance Taylor
  2009-06-10 15:28 ` skip_evaluation Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2009-06-10  0:59 UTC (permalink / raw)
  To: gcc

I have a question for C++ language lawyers.  The common part of the
C/C++ frontends has a global variable named skip_evaluation.  Both
frontends set this variable while parsing an expression inside sizeof
and friends.  This has the effect of disabling various warnings which
are irrelevant for code which is not going to be executed.  The C
frontend also sets skip_evaluation for constructs like (0 ? x : y) when
parsing the portion of the expression which will never be executed.  The
C++ frontend does not do this.

My question is whether it would be OK for the C++ frontend to also set
skip_evaluation for (0 ? x : y) or whether I should introduce a
different variable.


In asking this, I'm particularly puzzled by code like this in
build_base_path in cp/class.c:

  /* 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)
    {
      expr = build_nop (build_pointer_type (target_type), expr);
      if (!want_pointer)
	expr = build_indirect_ref (EXPR_LOCATION (expr), expr, NULL);
      return expr;
    }

Presumably the early return is OK within a sizeof expression; it is OK
within an expression like (0 ? x : y)?


I want to handle this one way or another in the C++ frontend in order to
handle expressions like this in the generated file insn-modes.c:

#define MODE_MASK(m)                          \
  ((m) >= HOST_BITS_PER_WIDE_INT)             \
   ? ~(unsigned HOST_WIDE_INT) 0              \
   : ((unsigned HOST_WIDE_INT) 1 << (m)) - 1

When m >= HOST_BITS_PER_WIDE_INT is true, this generates a warning "left
shift count >= width of type".  In C this warning is disabled by
skip_evaluation.  I would like to implement the same feature in C++.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-10 17:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-10  0:59 skip_evaluation Ian Lance Taylor
2009-06-10 15:28 ` skip_evaluation Paolo Bonzini
2009-06-10 15:46   ` skip_evaluation Ian Lance Taylor
2009-06-10 15:51     ` skip_evaluation Paolo Bonzini
2009-06-10 17:04       ` skip_evaluation Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).