xref: /aosp_15_r20/external/clang/test/Modules/Werror.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: rm -rf %t
2*67e74705SXin Li// RUN: rm -rf %t-saved
3*67e74705SXin Li// RUN: mkdir -p %t-saved
4*67e74705SXin Li
5*67e74705SXin Li// Initial module build (-Werror=header-guard)
6*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
7*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella  \
8*67e74705SXin Li// RUN:     -Werror=header-guard
9*67e74705SXin Li// RUN: cp %t/Module.pcm %t-saved/Module.pcm
10*67e74705SXin Li
11*67e74705SXin Li// Building with looser -Werror options does not rebuild
12*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
13*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella
14*67e74705SXin Li// RUN: diff %t/Module.pcm %t-saved/Module.pcm
15*67e74705SXin Li
16*67e74705SXin Li// Make the build more restricted (-Werror)
17*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
18*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
19*67e74705SXin Li// RUN:     -Werror -Wno-incomplete-umbrella
20*67e74705SXin Li// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
21*67e74705SXin Li// RUN: cp %t/Module.pcm %t-saved/Module.pcm
22*67e74705SXin Li
23*67e74705SXin Li// Ensure -Werror=header-guard is less strict than -Werror
24*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
25*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
26*67e74705SXin Li// RUN:     -Werror=header-guard -Wno-incomplete-umbrella
27*67e74705SXin Li// RUN: diff %t/Module.pcm %t-saved/Module.pcm
28*67e74705SXin Li
29*67e74705SXin Li// But -Werror=unused is not, because some of its diags are DefaultIgnore
30*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
31*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
32*67e74705SXin Li// RUN:     -Werror=unused
33*67e74705SXin Li// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
34*67e74705SXin Li// RUN: cp %t/Module.pcm %t-saved/Module.pcm
35*67e74705SXin Li
36*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
37*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
38*67e74705SXin Li// RUN:     -Werror -Wno-incomplete-umbrella
39*67e74705SXin Li
40*67e74705SXin Li// FIXME: when rebuilding the module, take the union of the diagnostic options
41*67e74705SXin Li// so that we don't need to rebuild here
42*67e74705SXin Li// RUN-DISABLED: diff %t/Module.pcm %t-saved/Module.pcm
43*67e74705SXin Li
44*67e74705SXin Li// -Wno-everything, -Werror
45*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
46*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
47*67e74705SXin Li// RUN:     -Wno-everything -Wall -Werror
48*67e74705SXin Li// RUN: cp %t/Module.pcm %t-saved/Module.pcm
49*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
50*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
51*67e74705SXin Li// RUN:     -Wall -Werror
52*67e74705SXin Li// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
53*67e74705SXin Li
54*67e74705SXin Li// -pedantic, -Werror is not compatible with -Wall -Werror
55*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
56*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
57*67e74705SXin Li// RUN:     -Werror -pedantic
58*67e74705SXin Li// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
59*67e74705SXin Li// RUN: cp %t/Module.pcm %t-saved/Module.pcm
60*67e74705SXin Li
61*67e74705SXin Li// -pedantic-errors is less strict that -pedantic, -Werror
62*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
63*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
64*67e74705SXin Li// RUN:     -pedantic-errors
65*67e74705SXin Li// RUN: diff %t/Module.pcm %t-saved/Module.pcm
66*67e74705SXin Li
67*67e74705SXin Li// -Wsystem-headers does not affect non-system modules
68*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
69*67e74705SXin Li// RUN:     -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
70*67e74705SXin Li// RUN:     -pedantic-errors -Wsystem-headers
71*67e74705SXin Li// RUN: diff %t/Module.pcm %t-saved/Module.pcm
72*67e74705SXin Li
73*67e74705SXin Li// expected-no-diagnostics
74*67e74705SXin Li@import Module;
75