Bad DONE/FAIL usage in config/sh/sh.md

Horst von Brand vonbrand@inf.utfsm.cl
Wed Apr 8 08:35:00 GMT 1998


Toshiyasu Morita <tm@netcom.com> said:
> There's some bad usage of DONE/FAIL in config/sh/sh.md:
> 
>   if(expand_block_move (operands))
>      DONE;
>   else FAIL;
> 
> This expands out to:
> 
>   if(expand_block_move (operands))
>   { ... } ;                        <- note floating semicolon
>   else { ... } ;                   <- note floating semicolon

The "standard fix" for this is to define, e.g.:

#define DONE     do { /* whatever */ } while(0)

This way nobody can get hurt by using DONE as a normal statement. And a
smart compiler will get rid of the while anyway ;-)
-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513



More information about the Gcc-bugs mailing list