[llvm-bugs] [Bug 26489] New: improve error message for 'label prefixing declaration'

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 5 02:08:17 PST 2016


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

            Bug ID: 26489
           Summary: improve error message for 'label prefixing
                    declaration'
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I think the error message by clang can be more user friendly. When I put a
label before a declaration, I got "error: expected expression". Then I used gcc
and got to know the reason. 

$: cat t.c
void f() {
l1:
    int a = 1;
    goto l1;
}
$: clang-trunk t.c
t.c:3:5: error: expected expression
    int a = 1;
    ^
1 error generated.
$: gcc-trunk t.c
t.c: In function ‘f’:
t.c:3:5: error: a label can only be part of a statement and a declaration is
not a statement
     int a = 1;
     ^~~
$: clang-trunk -v
clang version 3.9.0 (trunk 259077) (llvm/trunk 259321)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$:

-- 
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/20160205/9a59869a/attachment.html>


More information about the llvm-bugs mailing list