[all-commits] [llvm/llvm-project] 882915: Enum conversion warning when one signed and other ...

Micah Weston via All-commits all-commits at lists.llvm.org
Mon May 9 07:16:35 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 882915df61e33f3a2b7f58e52f572717e1c11499
      https://github.com/llvm/llvm-project/commit/882915df61e33f3a2b7f58e52f572717e1c11499
  Author: Micah Weston <micahsweston at gmail.com>
  Date:   2022-05-09 (Mon, 09 May 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaChecking.cpp
    A clang/test/Sema/enum-enum-conversion.c
    M clang/test/Sema/enum-sign-conversion.c

  Log Message:
  -----------
  Enum conversion warning when one signed and other unsigned.

Ensures an -Wenum-conversion warning happens when one of the enums is
signed and the other is unsigned. Also adds a test file to verify these
warnings.

This warning would not happen since the -Wsign-conversion would make a
diagnostic then return, never allowing the -Wenum-conversion checks.

For example:

C
enum PE { P = -1 };
enum NE { N };
enum NE conv(enum PE E) { return E; }
Before this would only create a diagnostic with -Wsign-conversion and
never on -Wenum-conversion. Now it will create a diagnostic for both
-Wsign-conversion and -Wenum-conversion.

I could change it to just warn on -Wenum-conversion as that was what I
initially did. Seeing PR35200 (or GitHub Issue 316268), I let both
diagnostics check so that the sign conversion could generate a warning.




More information about the All-commits mailing list