www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15326] New: False positive for dangling else warning

https://issues.dlang.org/show_bug.cgi?id=15326

          Issue ID: 15326
           Summary: False positive for dangling else warning
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mathias.lang sociomantic.com

```
version (unittest)
private struct _NestedSym_
{
    static if ((void*).sizeof == 8)
    {
        pragma(msg, "64");
    }
    else
    {
        pragma(msg, "32");
    }

    version (X86_64)
    {
        pragma(msg, "X86_64");
    }
    else
    {
        pragma(msg, "Not 64");
    }
}
```

```
% dmd -unittest -c -w test.d
test.d(8): Warning: else is dangling, add { } after condition at test.d(2)
test.d(17): Warning: else is dangling, add { } after condition at test.d(2)
```

Using `version(unittest):` makes the warning vanish.
Tested in both 2.066 and 2.069.

--
Nov 13 2015