[all-commits] [llvm/llvm-project] 11da1b: [C89/C2x] Improve diagnostics around strict protot...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Fri Apr 8 13:23:59 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 11da1b53d8cd3507959022cd790d5a7ad4573d94
      https://github.com/llvm/llvm-project/commit/11da1b53d8cd3507959022cd790d5a7ad4573d94
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2022-04-08 (Fri, 08 Apr 2022)

  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/SemaDecl.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/test/CodeGen/2009-06-01-addrofknr.c
    M clang/test/FixIt/fixit.c
    M clang/test/Parser/declarators.c
    M clang/test/Parser/knr_parameter_attributes.c
    M clang/test/Parser/opencl-kernel.cl
    M clang/test/Parser/traditional_arg_scope.c
    M clang/test/Sema/arg-duplicate.c
    M clang/test/Sema/block-return.c
    M clang/test/Sema/knr-def-call.c
    M clang/test/Sema/knr-variadic-def.c
    M clang/test/Sema/vfprintf-valid-redecl.c
    A clang/test/Sema/warn-deprecated-non-prototype.c
    M clang/test/Sema/warn-missing-prototypes.c
    M clang/test/Sema/warn-strict-prototypes.c
    M clang/test/Sema/warn-strict-prototypes.m
    M clang/test/SemaObjC/nonnull.m
    M clang/test/SemaOpenCL/address-spaces.cl
    M clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
    M clang/test/SemaOpenCL/func.cl

  Log Message:
  -----------
  [C89/C2x] Improve diagnostics around strict prototypes in C

Functions without prototypes in C (also known as K&R C functions) were
introduced into C89 as a deprecated feature and C2x is now reclaiming
that syntax space with different semantics. However, Clang's
-Wstrict-prototypes diagnostic is off-by-default (even in pedantic
mode) and does not suffice to warn users about issues in their code.

This patch changes the behavior of -Wstrict-prototypes to only diagnose
declarations and definitions which are not going to change behavior in
C2x mode, and enables the diagnostic in -pedantic mode. The diagnostic
is now specifically about the fact that the feature is deprecated.

It also adds -Wdeprecated-non-prototype, which is grouped under
-Wstrict-prototypes and diagnoses declarations or definitions which
will change behavior in C2x mode. This diagnostic is enabled by default
because the risk is higher for the user to continue to use the
deprecated feature.

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




More information about the All-commits mailing list