[PATCH] D134461: [Clang] Diagnose an error when trying to deferencing void pointers in C
Jun Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 22 10:59:05 PDT 2022
junaire created this revision.
junaire added reviewers: aaron.ballman, pmor13.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Previously we only have an extension that warn void pointer deferencing
in C++, but for C we did nothing.
C2x 6.5.3.2p4 says The unary * operator denotes indirection. If it points
to an object, the result is an lvalue designating the object. However, there
is no way to form an lvalue designating an object of an incomplete type as
6.3.2.1p1 says "an lvalue is an expression (with an object type other than
void)", so the behavior is undefined.
Fixes https://github.com/llvm/llvm-project/issues/53631
Signed-off-by: Jun Zhang <jun at junz.org>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134461
Files:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Analysis/misc-ps.m
clang/test/C/drs/dr1xx.c
clang/test/Sema/asm.c
clang/test/Sema/builtins-arm.c
clang/test/Sema/conditional-expr.c
clang/test/Sema/expr-address-of.c
clang/test/Sema/i-c-e.c
clang/test/Sema/warn-deference-void-ptr.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134461.462243.patch
Type: text/x-patch
Size: 17634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220922/45a9439b/attachment-0001.bin>
More information about the cfe-commits
mailing list