[all-commits] [llvm/llvm-project] e07ead: [Clang] Warn when trying to dereference void point...

Jun Zhang via All-commits all-commits at lists.llvm.org
Sat Sep 24 07:20:16 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e07ead85a368173a56e96a21d6841aa497ad80f8
      https://github.com/llvm/llvm-project/commit/e07ead85a368173a56e96a21d6841aa497ad80f8
  Author: Jun Zhang <jun at junz.org>
  Date:   2022-09-24 (Sat, 24 Sep 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Parse/ParseExpr.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/Analysis/misc-ps.m
    M clang/test/C/drs/dr0xx.c
    M clang/test/C/drs/dr1xx.c
    M clang/test/Sema/asm.c
    M clang/test/Sema/builtins-arm.c
    M clang/test/Sema/conditional-expr.c
    M clang/test/Sema/deref.c
    M clang/test/Sema/expr-address-of.c
    M clang/test/Sema/i-c-e.c

  Log Message:
  -----------
  [Clang] Warn when trying to dereference void pointers in C

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>

Differential Revision: https://reviews.llvm.org/D134461




More information about the All-commits mailing list