[Sema] Adds the pointer-to-int-cast diagnostic
authorMark de Wever <koraq@xs4all.nl>
Sun, 16 Feb 2020 14:01:25 +0000 (15:01 +0100)
committerMark de Wever <koraq@xs4all.nl>
Sun, 16 Feb 2020 14:38:25 +0000 (15:38 +0100)
commit9658d895c81aeb849b412b9332c88769588c7660
tree5ff3667dba4a4019c6ce586894095ce80984d6a2
parent1b04866a3db9f816a559860f941da067fe1eccf1
[Sema] Adds the pointer-to-int-cast diagnostic

Converting a pointer to an integer whose result cannot represented in the
integer type is undefined behavior is C and prohibited in C++. C++ already
has a diagnostic when casting. This adds a diagnostic for C.

Since this diagnostic uses the range of the conversion it also modifies
int-to-pointer-cast diagnostic to use a range.

Fixes PR8718: No warning on casting between pointer and non-pointer-sized int

Differential Revision: https://reviews.llvm.org/D72231
23 files changed:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/test/Analysis/bstring.c
clang/test/Analysis/casts.c
clang/test/Analysis/misc-ps.c
clang/test/Analysis/misc-ps.m
clang/test/Analysis/ptr-arith.c
clang/test/Analysis/svalbuilder-logic.c
clang/test/Analysis/symbol-reaper.c
clang/test/CodeGen/const-init.c
clang/test/Sema/MicrosoftExtensions.c
clang/test/Sema/block-return.c
clang/test/Sema/cast.c
clang/test/Sema/const-eval.c
clang/test/Sema/init.c
clang/test/Sema/offsetof.c
clang/test/Sema/static-init.c
clang/test/Sema/struct-decl.c
clang/test/SemaObjC/arc.m
clang/test/SemaObjC/gcc-cast-ext.m
clang/test/SemaObjC/protocol-archane.m