]> granicus.if.org Git - clang/commitdiff
[Sema] Document+test the -Wsign-conversion change for enums in C code [NFC]
authorRoman Lebedev <lebedev.ri@gmail.com>
Sat, 4 Nov 2017 20:27:47 +0000 (20:27 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sat, 4 Nov 2017 20:27:47 +0000 (20:27 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317421 91177308-0d34-0410-b5e6-96231b3b80d8

docs/ReleaseNotes.rst
test/Sema/enum-sign-conversion.c [new file with mode: 0644]

index 4c8099121ef51a14e7b5de122b7fc95f91fb8df1..8699812496acdd16d8e70bca2111b1d6f3cbae63 100644 (file)
@@ -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``.
 
diff --git a/test/Sema/enum-sign-conversion.c b/test/Sema/enum-sign-conversion.c
new file mode 100644 (file)
index 0000000..518fc67
--- /dev/null
@@ -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
+}