[llvm-bugs] [Bug 27493] New: -Wdeclaration-after-statement not working

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 23 10:18:25 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27493

            Bug ID: 27493
           Summary: -Wdeclaration-after-statement not working
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jhi at iki.fi
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ cat das.c
int foo() {
  if (0) {}
  int i = 42;
  return i;
}
$ clang-mp-3.7 -Wdeclaration-after-statement -c das.c

Nothing.  As opposed to:

gcc-mp-5 -Wdeclaration-after-statement -c das.c
das.c: In function 'foo':
das.c:3:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
   int i = 42;
   ^

Note that I'm using the macports clang and gcc.  Their versions:

$ clang-mp-3.7 -v
clang version 3.7.1 (tags/RELEASE_371/final)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
$ gcc-mp-5 -v
...
gcc version 5.3.0 (MacPorts gcc5 5.3.0_0)

I tried clangs 3.4, 3.5, 3.6, the same result of no warning.

I tried gccs 4.3, 4.4, 4.5, 4.6, 4.8, 4.9, emit the warning.

I also finally tried clang 3.4 on a Ubuntu precise VM, the same result of no
warning.

Don't have a clang 3.8 installation available.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160423/595e93b4/attachment.html>


More information about the llvm-bugs mailing list