summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Index/pch-warn-as-error-code-split.cpp17
-rw-r--r--clang/test/Index/pch-warn-as-error-code-split.h4
-rw-r--r--clang/test/Index/pch-warn-as-error-code.cpp27
-rw-r--r--clang/test/PCH/chain-invalid-code.cpp28
4 files changed, 76 insertions, 0 deletions
diff --git a/clang/test/Index/pch-warn-as-error-code-split.cpp b/clang/test/Index/pch-warn-as-error-code-split.cpp
new file mode 100644
index 00000000000..115c9e3d317
--- /dev/null
+++ b/clang/test/Index/pch-warn-as-error-code-split.cpp
@@ -0,0 +1,17 @@
+// RUN: CINDEXTEST_EDITING=1 c-index-test -test-load-source local %s -Wuninitialized -Werror=unused 2>&1 | FileCheck -check-prefix=DIAGS %s
+
+// Make sure -Wuninitialized works even though the header had a warn-as-error occurrence.
+
+// DIAGS: error: unused variable 'x'
+// DIAGS: warning: variable 'x1' is uninitialized
+// DIAGS-NOT: error: use of undeclared identifier
+// DIAGS: warning: variable 'x1' is uninitialized
+
+#include "pch-warn-as-error-code-split.h"
+
+void test() {
+ int x1; // expected-note {{initialize}}
+ int x2 = x1; // expected-warning {{uninitialized}}
+ (void)x2;
+ foo_head();
+}
diff --git a/clang/test/Index/pch-warn-as-error-code-split.h b/clang/test/Index/pch-warn-as-error-code-split.h
new file mode 100644
index 00000000000..5893ee2a3f7
--- /dev/null
+++ b/clang/test/Index/pch-warn-as-error-code-split.h
@@ -0,0 +1,4 @@
+
+static void foo_head() {
+ int x;
+}
diff --git a/clang/test/Index/pch-warn-as-error-code.cpp b/clang/test/Index/pch-warn-as-error-code.cpp
new file mode 100644
index 00000000000..6a7924a09e6
--- /dev/null
+++ b/clang/test/Index/pch-warn-as-error-code.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -f %t.head.h.pch
+// RUN: c-index-test -write-pch %t.head.h.pch %s -Wuninitialized -Werror=unused 2>&1 | FileCheck -check-prefix=HEAD_DIAGS %s
+// RUN: c-index-test -test-load-source local %s -include %t.head.h -Wuninitialized -Werror=unused 2>&1 | FileCheck -check-prefix=MAIN_DIAGS %s
+
+// Make sure -Wuninitialized works even though the header had a warn-as-error occurrence.
+
+// HEAD_DIAGS: error: unused variable 'x'
+// MAIN_DIAGS: warning: variable 'x1' is uninitialized
+// MAIN_DIAGS-NOT: error: use of undeclared identifier
+
+#ifndef HEADER
+#define HEADER
+
+static void foo_head() {
+ int x;
+}
+
+#else
+
+void test() {
+ int x1; // expected-note {{initialize}}
+ int x2 = x1; // expected-warning {{uninitialized}}
+ (void)x2;
+ foo_head();
+}
+
+#endif
diff --git a/clang/test/PCH/chain-invalid-code.cpp b/clang/test/PCH/chain-invalid-code.cpp
new file mode 100644
index 00000000000..9de88f0cee7
--- /dev/null
+++ b/clang/test/PCH/chain-invalid-code.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only %s -chain-include %s -Wuninitialized -Wunused -verify
+
+// Make sure there is no crash.
+
+#ifndef HEADER
+#define HEADER
+
+#include "non-existent-header.h"
+
+class A {
+public:
+ ~A();
+};
+
+class ForwardCls;
+struct B {
+ ForwardCls f;
+ A a;
+};
+
+#else
+
+static void test() {
+ int x; // expected-warning {{unused}}
+ B b;
+}
+
+#endif
OpenPOWER on IntegriCloud