[llvm-bugs] [Bug 28212] New: No diagnostic for declarations with incompatible enums
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jun 20 10:39:03 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28212
Bug ID: 28212
Summary: No diagnostic for declarations with incompatible enums
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: ch3root at openwall.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
It seem the declaration (1) makes clang miss incompatibility of types between
the declarations (2) and (3). This is a constraints violation:
C11, 6.7p4: "All declarations in the same scope that refer to the same object
or function shall specify compatible types."
Source code:
----------------------------------------------------------------------
unsigned x; // (1)
enum { a } x; // (2)
enum { b } x; // (3)
int main()
{
}
----------------------------------------------------------------------
Results:
----------------------------------------------------------------------
$ clang -std=c11 -Weverything -O3 test.c && ./a.out
test.c:2:12: warning: no previous extern declaration for non-static variable
'x' [-Wmissing-variable-declarations]
enum { a } x;
^
1 warning generated.
----------------------------------------------------------------------
clang version: clang version 3.9.0 (trunk 271312)
For comparison:
----------------------------------------------------------------------
$ gcc -std=c11 -pedantic -Wall -Wextra -O3 test.c && ./a.out
test.c:3:12: error: conflicting types for ‘x’
enum { b } x;
^
test.c:2:12: note: previous declaration of ‘x’ was here
enum { a } x;
^
----------------------------------------------------------------------
gcc version: gcc (GCC) 7.0.0 20160616 (experimental)
--
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/20160620/a7604b27/attachment.html>
More information about the llvm-bugs
mailing list