https://bugs.llvm.org/show_bug.cgi?id=49337
Bug ID: 49337
Summary: accept-invalid: __builtin_types_compatible_p pollutes
the environment of tag type checking
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: zhan3...@purdue.edu
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
I am not sure how to accurately describe the problem. In short,
Following code is obviously invalid, as the use of 'X' with tag type does not
match previous declaration (https://godbolt.org/z/qad8vz).
$ cat case1.c
struct X {
union X {
int b;
long c;
} d;
} a;
int main() { return 0; }
However, when we put this erroneous declaration into a
__builtin_types_compatible_p function, clang accepts it
(https://godbolt.org/z/TrxTzs). Note that it is rejected by GCC
(https://godbolt.org/z/rWde88).
$ cat case2.c
int main() {
int a = __builtin_types_compatible_p(int, struct X {
union X {
int b;
long c;
} d;
});
return a;
}
Even worse, this invalid __builtin_types_compatible_p may additionally affects
other statements (https://godbolt.org/z/avxvzj), which, at least, gives the
wrong error reports.
$ cat case3.c
int main() {
int a = __builtin_types_compatible_p(int, struct X {
union X {
int b;
long c;
} d;
});
enum X { A, B } h;
h = A;
return a;
}
$ clang case3.c
#1 with x86-64 clang (trunk)
case3.c:10:9: error: use of undeclared identifier 'A'
h = A;
^
1 error generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs