[Issue 2423] Erroneous unreachable statement warning

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 7 08:35:27 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2423


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugdbug at yahoo.com.au




--- Comment #6 from Don <clugdbug at yahoo.com.au>  2009-08-07 08:35:26 PDT ---
To remove the warning from empty statements:

PATCH:
statement.c, line 564 (DMD2)

-        if (!(result & BEfallthru) && !s->comeFrom())
+        if (!(result & BEfallthru) && !s->comeFrom() && !s->isEmpty())
        {
        s->warning("statement is not reachable");
        }

And then add this line to ExpStatement, in statement.h line 140:

    virtual int isEmpty() { return exp==NULL; }


Side effect: This will make {;;;;;} an empty statement; at the moment, it
isn't. The patch below makes the code below compile (into return 2;). Currently
it won't compile, but works if try{;} is changed into try{}.

nothrow int main() {
 int x= 2;
 try { ; } catch(Exception e) { x=4; throw new Exception("xxx"); } 
 return x;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list