public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* switch question in recog.c
@ 2003-10-07 18:54 Andrew MacLeod
  2003-10-07 18:59 ` Daniel Jacobowitz
  2003-10-07 19:09 ` Dale Johannesen
  0 siblings, 2 replies; 14+ messages in thread
From: Andrew MacLeod @ 2003-10-07 18:54 UTC (permalink / raw)
  To: gcc mailing list

Is this really valid? Sure seems screwy to me.


in the function asm_operand_ok(), the code looks like:

<...>
        case 'X':
          result = 1;

        case 'g':
          if (general_operand (op, VOIDmode))
            result = 1;
          break;

        default:
          /* For all other letters, we first check for a register class,
             otherwise it is an EXTRA_CONSTRAINT.  */
          if (REG_CLASS_FROM_CONSTRAINT (c, constraint) != NO_REGS)
            {
            case 'r':
              if (GET_MODE (op) == BLKmode)
                break;
              if (register_operand (op, VOIDmode))
                result = 1;
            }
#ifdef EXTRA_CONSTRAINT_STR
          if (EXTRA_CONSTRAINT_STR (op, c, constraint))
            result = 1;
          if (EXTRA_MEMORY_CONSTRAINT (c, constraint))
<...>

Look at where the case 'r' is.. its inside the 'default:' case. Is that
really kosher?


Andrew


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: switch question in recog.c
@ 2003-10-07 19:31 Chris Lattner
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Lattner @ 2003-10-07 19:31 UTC (permalink / raw)
  To: gcc


> Huh. I would have failed that question miserably after using the
> language for 20 years. It would never occur to me to put a case after
> the default label, let alone inside a control structure of some sort.
> How miserable :-) But you are right, the standard doesnt appear to
> disallow it that I can see.

If you like this, you might like "Duff's Device", which abuses switch
statements even worse:
http://www.lysator.liu.se/c/duffs-device.html

I'm happy LLVM doesn't have to worry about this stuff. :)

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/


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

end of thread, other threads:[~2003-10-12 23:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-07 18:54 switch question in recog.c Andrew MacLeod
2003-10-07 18:59 ` Daniel Jacobowitz
2003-10-07 19:16   ` Andrew MacLeod
2003-10-07 19:32     ` Joe Buck
2003-10-07 22:27     ` Michael Matz
2003-10-07 22:33       ` DJ Delorie
2003-10-07 22:38         ` Michael Matz
2003-10-07 22:46           ` Erik Trulsson
2003-10-07 23:03             ` Michael Matz
2003-10-07 22:34       ` Zack Weinberg
2003-10-13  2:15         ` Nix
2003-10-07 19:09 ` Dale Johannesen
2003-10-07 21:08   ` Richard Henderson
2003-10-07 19:31 Chris Lattner

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).