r200054 - Add a proper test for -Wsystem-headers

Alp Toker alp at nuanti.com
Fri Jan 24 16:32:41 PST 2014


Author: alp
Date: Fri Jan 24 18:32:40 2014
New Revision: 200054

URL: http://llvm.org/viewvc/llvm-project?rev=200054&view=rev
Log:
Add a proper test for -Wsystem-headers

This will be extended as we fix issues in the current implementation.

Added:
    cfe/trunk/test/Headers/warn-sysheader.cpp

Added: cfe/trunk/test/Headers/warn-sysheader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/warn-sysheader.cpp?rev=200054&view=auto
==============================================================================
--- cfe/trunk/test/Headers/warn-sysheader.cpp (added)
+++ cfe/trunk/test/Headers/warn-sysheader.cpp Fri Jan 24 18:32:40 2014
@@ -0,0 +1,33 @@
+// Test that -Wsystem-headers works with default and custom mappings like -Werror.
+// Keep run lines at the bottom for line number stability.
+
+#ifdef IS_SYSHEADER
+#pragma clang system_header
+
+int f() { return (int)0; } // Use the old-style-cast warning as an arbitrary "ordinary" diagnostic for the purpose of testing.
+
+#warning "custom message"
+
+#if defined(A) || defined(B)
+// expected-warning at 9 {{"custom message"}}
+#elif defined(C)
+// expected-warning at 7 {{use of old-style cast}}
+// expected-warning at 9 {{"custom message"}}
+#elif defined(D)
+// expected-error at 7 {{use of old-style cast}}
+// expected-error at 9 {{"custom message"}}
+#elif defined(E)
+// expected-error at 7 {{use of old-style cast}}
+// expected-warning at 9 {{"custom message"}}
+#endif
+
+#else
+#define IS_SYSHEADER
+#include __FILE__
+#endif
+
+// RUN: %clang_cc1 -verify -fsyntax-only -DA %s
+// RUN: %clang_cc1 -verify -fsyntax-only -DB -Wold-style-cast %s
+// RUN: %clang_cc1 -verify -fsyntax-only -DC -Wold-style-cast -Wsystem-headers %s
+// RUN: %clang_cc1 -verify -fsyntax-only -DD -Wold-style-cast -Wsystem-headers -Werror %s
+// RUN: %clang_cc1 -verify -fsyntax-only -DE -Wold-style-cast -Wsystem-headers -Werror=old-style-cast %s





More information about the cfe-commits mailing list