summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2017-11-04 20:27:47 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2017-11-04 20:27:47 +0000
commitd9af8e1f981ddf68d13b2aead4b8c9598b3ea46b (patch)
tree93a7ec79cb301868221162f0b7b5b6ba2e04c5e3 /clang
parentcbaf5a4f50d7ad4f2b066a001274a7836bd594ba (diff)
downloadbcm5719-llvm-d9af8e1f981ddf68d13b2aead4b8c9598b3ea46b.tar.gz
bcm5719-llvm-d9af8e1f981ddf68d13b2aead4b8c9598b3ea46b.zip
[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 llvm-svn: 317421
Diffstat (limited to 'clang')
-rw-r--r--clang/docs/ReleaseNotes.rst3
-rw-r--r--clang/test/Sema/enum-sign-conversion.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4c8099121ef..8699812496a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -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/clang/test/Sema/enum-sign-conversion.c b/clang/test/Sema/enum-sign-conversion.c
new file mode 100644
index 00000000000..518fc670d31
--- /dev/null
+++ b/clang/test/Sema/enum-sign-conversion.c
@@ -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
+}
OpenPOWER on IntegriCloud