r317421 - [Sema] Document+test the -Wsign-conversion change for enums in C code [NFC]

Roman Lebedev via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 4 13:27:47 PDT 2017


Author: lebedevri
Date: Sat Nov  4 13:27:47 2017
New Revision: 317421

URL: http://llvm.org/viewvc/llvm-project?rev=317421&view=rev
Log:
[Sema] Document+test the -Wsign-conversion change for enums in C code [NFC]

Basically a regression after r316268.
However the diagnostic is correct, but the test coverage is bad.

So just like rL316500, introduce yet more tests,
and adjust the release notes.

See https://bugs.llvm.org/show_bug.cgi?id=35200

Added:
    cfe/trunk/test/Sema/enum-sign-conversion.c
Modified:
    cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=317421&r1=317420&r2=317421&view=diff
==============================================================================
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sat Nov  4 13:27:47 2017
@@ -82,7 +82,8 @@ Improvements to Clang's diagnostics
   tautological comparisons between integer variable of the type ``T`` and the
   largest/smallest possible integer constant of that same type.
 
-- For C code, ``-Wsign-compare``, ``-Wtautological-constant-compare`` and
+- For C code, ``-Wsign-compare``, ``-Wsign-conversion``,
+  ``-Wtautological-constant-compare`` and
   ``-Wtautological-constant-out-of-range-compare`` were adjusted to use the
   underlying datatype of ``enum``.
 

Added: cfe/trunk/test/Sema/enum-sign-conversion.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum-sign-conversion.c?rev=317421&view=auto
==============================================================================
--- cfe/trunk/test/Sema/enum-sign-conversion.c (added)
+++ cfe/trunk/test/Sema/enum-sign-conversion.c Sat Nov  4 13:27:47 2017
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -DUNSIGNED -Wsign-conversion %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wsign-conversion %s
+
+// PR35200
+enum X { A,B,C};
+int f(enum X x) {
+#ifdef UNSIGNED
+  return x; // expected-warning {{implicit conversion changes signedness: 'enum X' to 'int'}}
+#else
+  // expected-no-diagnostics
+  return x;
+#endif
+}




More information about the cfe-commits mailing list