[all-commits] [llvm/llvm-project] 9cb00b: Reland Produce warning for performing pointer arit...

jamieschmeiser via All-commits all-commits at lists.llvm.org
Tue Jul 20 07:12:56 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9cb00b9ecbe74d19389a5818d61ddee328afe031
      https://github.com/llvm/llvm-project/commit/9cb00b9ecbe74d19389a5818d61ddee328afe031
  Author: Jamie Schmeiser <schmeise at ca.ibm.com>
  Date:   2021-07-20 (Tue, 20 Jul 2021)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaExpr.cpp
    A clang/test/Sema/Inputs/pointer-subtraction.h
    A clang/test/Sema/pointer-subtraction.c
    A clang/test/Sema/pointer-subtraction.cpp

  Log Message:
  -----------
  Reland Produce warning for performing pointer arithmetic on a null pointer.

Summary:
Test and produce warning for subtracting a pointer from null or subtracting
null from a pointer.

This reland adds the functionality that the warning is no longer reusing an
existing warning, it has different wording for C vs C++ to refect the fact
that nullptr-nullptr has defined behaviour in C++,  it is suppressed
when the warning is triggered by a system header and adds
-Wnull-pointer-subtraction to allow the warning to be controlled.  -Wextra
implies -Wnull-pointer-subtraction.

Author: Jamie Schmeiser <schmeise at ca.ibm.com>
Reviewed By: efriedma (Eli Friedman), nickdesaulniers (Nick Desaulniers)
Differential Revision: https://reviews.llvm.org/D98798




More information about the All-commits mailing list