xref: /aosp_15_r20/external/clang/test/Misc/serialized-diags-driver.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test that the driver correctly combines its own diagnostics with CC1's in the
2*67e74705SXin Li // serialized diagnostics. To test this, we need to trigger diagnostics from
3*67e74705SXin Li // both processes, so we compile code that has a warning (with an associated
4*67e74705SXin Li // note) and then force the driver to crash. We compile stdin so that the crash
5*67e74705SXin Li // doesn't litter the user's system with preprocessed output.
6*67e74705SXin Li 
7*67e74705SXin Li // RUN: rm -f %t
8*67e74705SXin Li // RUN: %clang -Wx-typoed-warning -Wall -fsyntax-only --serialize-diagnostics %t.diag %s
9*67e74705SXin Li // RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
10*67e74705SXin Li 
11*67e74705SXin Li // CHECK: warning: unknown warning option '-Wx-typoed-warning' [-Wunknown-warning-option] []
12*67e74705SXin Li 
13*67e74705SXin Li // CHECK: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
14*67e74705SXin Li // CHECK: note: initialize the variable 'voodoo' to silence this warning []
15*67e74705SXin Li // CHECK: Number of diagnostics: 2
16*67e74705SXin Li 
foo()17*67e74705SXin Li void foo() {
18*67e74705SXin Li   int voodoo;
19*67e74705SXin Li   voodoo = voodoo + 1;
20*67e74705SXin Li }
21