Skip to content

Commit 56c4971

Browse files
committed
[Driver,test] Replace CHECK-NOT: warning with -### -Werror
After https://reviews.llvm.org/D156363 changed -### to exist with code 1 if hasErrorOccurred, we can use -Werror to assert no warnings. This is more reliable than a NOT pattern, which may go stale (when the diagnostic is updated) without being noticed.
1 parent ac45bb5 commit 56c4971

File tree

4 files changed

+19
-36
lines changed

4 files changed

+19
-36
lines changed

clang/test/Driver/claim-unused.c

Lines changed: 0 additions & 3 deletions
This file was deleted.

clang/test/Driver/fp-model.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@
7373

7474
// RUN: %clang -### -Ofast -ffp-model=strict -c %s 2>&1 | FileCheck \
7575
// RUN: --check-prefix=WARN12 %s
76-
// RUN: %clang -### -ffast-math -ffp-model=strict -c %s 2>&1 | FileCheck \
77-
// RUN: --check-prefix=WARN12 %s
78-
// WARN12-NOT: warning: overriding '-ffp-model=strict' option with '-ffp-model=strict' [-Woverriding-option]
76+
// RUN: %clang -### -Werror -ffast-math -ffp-model=strict -c %s
77+
// WARN12: warning: overriding '-ffp-model=strict' option with '-Ofast'
7978

8079
// RUN: %clang -### -ffp-model=strict -fapprox-func -c %s 2>&1 \
8180
// RUN: | FileCheck --check-prefix=WARN13 %s

clang/test/Driver/gcc-param.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: touch %t.o
2+
// RUN: %clang -Werror --param ssp-buffer-size=1 %t.o -###

clang/test/Driver/linux-ld.c

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
// General tests that ld invocations on Linux targets sane. Note that we use
33
// sysroot to make these tests independent of the host system.
44
//
5-
// RUN: %clang -### %s -no-pie 2>&1 \
5+
// RUN: %clang -### -Werror %s -no-pie 2>&1 \
66
// RUN: --target=i386-unknown-linux -rtlib=platform --unwindlib=platform \
77
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
88
// RUN: | FileCheck --check-prefix=CHECK-LD-32 %s
9-
// CHECK-LD-32-NOT: warning:
109
// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
1110
// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/10.2.0{{/|\\\\}}crtbegin.o"
1211
// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/10.2.0"
1312
// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/10.2.0/../../../../i386-unknown-linux/lib"
1413
// CHECK-LD-32: "-L[[SYSROOT]]/lib"
1514
// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib"
1615
//
17-
// RUN: %clang -### %s -no-pie 2>&1 \
16+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
1817
// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
1918
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
2019
// RUN: | FileCheck --check-prefix=CHECK-LD-64 %s
21-
// CHECK-LD-64-NOT: warning:
2220
// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
2321
// CHECK-LD-64: "--eh-frame-hdr"
2422
// CHECK-LD-64: "-m" "elf_x86_64"
@@ -32,11 +30,10 @@
3230
// CHECK-LD-64: "-lc"
3331
// CHECK-LD-64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
3432
//
35-
// RUN: %clang -### %s -no-pie 2>&1 \
33+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
3634
// RUN: --target=x86_64-unknown-linux-gnux32 -rtlib=platform --unwindlib=platform \
3735
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
3836
// RUN: | FileCheck --check-prefix=CHECK-LD-X32 %s
39-
// CHECK-LD-X32-NOT: warning:
4037
// CHECK-LD-X32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
4138
// CHECK-LD-X32: "--eh-frame-hdr"
4239
// CHECK-LD-X32: "-m" "elf32_x86_64"
@@ -45,13 +42,12 @@
4542
// CHECK-LD-X32: "-lc"
4643
// CHECK-LD-X32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
4744
//
48-
// RUN: %clang -### %s -no-pie 2>&1 \
45+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
4946
// RUN: --target=x86_64-unknown-linux \
5047
// RUN: -resource-dir=%S/Inputs/resource_dir \
5148
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
5249
// RUN: --rtlib=compiler-rt \
5350
// RUN: | FileCheck --check-prefix=CHECK-LD-RT %s
54-
// CHECK-LD-RT-NOT: warning:
5551
// CHECK-LD-RT: "-resource-dir" "[[RESDIR:[^"]*]]"
5652
// CHECK-LD-RT: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
5753
// CHECK-LD-RT: "--eh-frame-hdr"
@@ -67,13 +63,12 @@
6763
// CHECK-LD-RT: libclang_rt.builtins.a"
6864
// CHECK-LD-RT: "[[RESDIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-linux{{/|\\\\}}clang_rt.crtend.o"
6965
//
70-
// RUN: %clang -### %s -no-pie 2>&1 \
66+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
7167
// RUN: --target=i686-unknown-linux \
7268
// RUN: -resource-dir=%S/Inputs/resource_dir \
7369
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
7470
// RUN: --rtlib=compiler-rt \
7571
// RUN: | FileCheck --check-prefix=CHECK-LD-RT-I686 %s
76-
// CHECK-LD-RT-I686-NOT: warning:
7772
// CHECK-LD-RT-I686: "-resource-dir" "[[RESDIR:[^"]*]]"
7873
// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
7974
// CHECK-LD-RT-I686: "--eh-frame-hdr"
@@ -89,13 +84,12 @@
8984
// CHECK-LD-RT-I686: libclang_rt.builtins.a"
9085
// CHECK-LD-RT-I686: "[[RESDIR]]{{/|\\\\}}lib{{/|\\\\}}i686-unknown-linux{{/|\\\\}}clang_rt.crtend.o"
9186
//
92-
// RUN: %clang -### %s -no-pie 2>&1 \
87+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
9388
// RUN: --target=arm-linux-androideabi \
9489
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
9590
// RUN: -resource-dir=%S/Inputs/resource_dir \
9691
// RUN: --rtlib=compiler-rt \
9792
// RUN: | FileCheck --check-prefix=CHECK-LD-RT-ANDROID %s
98-
// CHECK-LD-RT-ANDROID-NOT: warning:
9993
// CHECK-LD-RT-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
10094
// CHECK-LD-RT-ANDROID: "--eh-frame-hdr"
10195
// CHECK-LD-RT-ANDROID: "-m" "armelf_linux_eabi"
@@ -104,11 +98,10 @@
10498
// CHECK-LD-RT-ANDROID: "-lc"
10599
// CHECK-LD-RT-ANDROID: libclang_rt.builtins.a"
106100
//
107-
// RUN: %clang -### %s -no-pie 2>&1 \
101+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
108102
// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
109103
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
110104
// RUN: | FileCheck --check-prefix=CHECK-LD-GCC %s
111-
// CHECK-LD-GCC-NOT: warning:
112105
// CHECK-LD-GCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
113106
// CHECK-LD-GCC: "--eh-frame-hdr"
114107
// CHECK-LD-GCC: "-m" "elf_x86_64"
@@ -122,12 +115,11 @@
122115
// CHECK-LD-GCC: "-lc"
123116
// CHECK-LD-GCC: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
124117
//
125-
// RUN: %clang -### %s -no-pie 2>&1 \
118+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
126119
// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
127120
// RUN: -static-libgcc \
128121
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
129122
// RUN: | FileCheck --check-prefix=CHECK-LD-64-STATIC-LIBGCC %s
130-
// CHECK-LD-64-STATIC-LIBGCC-NOT: warning:
131123
// CHECK-LD-64-STATIC-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
132124
// CHECK-LD-64-STATIC-LIBGCC: "--eh-frame-hdr"
133125
// CHECK-LD-64-STATIC-LIBGCC: "-m" "elf_x86_64"
@@ -268,12 +260,10 @@
268260
// CHECK-CLANG-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
269261
// CHECK-CLANG-ANDROID-STATIC: "--start-group" "{{[^"]*}}{{/|\\\\}}libclang_rt.builtins.a" "-l:libunwind.a" "-lc" "--end-group"
270262
//
271-
// RUN: %clang -### %s 2>&1 \
272-
// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
263+
// RUN: %clang -### %s -Werror --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
273264
// RUN: -static \
274-
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
265+
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
275266
// RUN: | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
276-
// CHECK-LD-64-STATIC-NOT: warning:
277267
// CHECK-LD-64-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
278268
// CHECK-LD-64-STATIC: "--eh-frame-hdr"
279269
// CHECK-LD-64-STATIC: "-m" "elf_x86_64"
@@ -486,13 +476,12 @@
486476
//
487477
// Test that we can use -stdlib=libc++ in a build system even when it
488478
// occasionally links C code instead of C++ code.
489-
// RUN: %clang -x c -### %s -no-pie 2>&1 \
479+
// RUN: %clang -x c -### %s -Werror -no-pie 2>&1 \
490480
// RUN: --target=x86_64-unknown-linux-gnu \
491481
// RUN: -stdlib=libc++ \
492482
// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
493483
// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
494484
// RUN: | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-C-LINK %s
495-
// CHECK-BASIC-LIBCXX-C-LINK-NOT: warning:
496485
// CHECK-BASIC-LIBCXX-C-LINK: "-cc1"
497486
// CHECK-BASIC-LIBCXX-C-LINK: "-isysroot" "[[SYSROOT:[^"]+]]"
498487
// CHECK-BASIC-LIBCXX-C-LINK-NOT: "-internal-isystem" "[[SYSROOT]]/usr/bin/../include/c++/v1"
@@ -1661,11 +1650,10 @@
16611650
// CHECK-MUSL-AARCH64_BE: "-dynamic-linker" "/lib/ld-musl-aarch64_be.so.1"
16621651

16631652
// Check whether multilib gcc install works fine on Gentoo with gcc-config
1664-
// RUN: %clang -### %s -no-pie 2>&1 \
1653+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
16651654
// RUN: --target=x86_64-unknown-linux-gnu -rtlib=platform --unwindlib=platform \
16661655
// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
16671656
// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO %s
1668-
// CHECK-LD-GENTOO-NOT: warning:
16691657
// CHECK-LD-GENTOO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
16701658
// CHECK-LD-GENTOO: "--eh-frame-hdr"
16711659
// CHECK-LD-GENTOO: "-m" "elf_x86_64"
@@ -1676,11 +1664,10 @@
16761664
// CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
16771665
// CHECK-LD-GENTOO: "-lc"
16781666
// CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
1679-
// RUN: %clang -### %s -no-pie 2>&1 \
1667+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
16801668
// RUN: --target=i686-unknown-linux-gnu -rtlib=platform --unwindlib=platform \
16811669
// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
16821670
// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO-32 %s
1683-
// CHECK-LD-GENTOO-32-NOT: warning:
16841671
// CHECK-LD-GENTOO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
16851672
// CHECK-LD-GENTOO-32: "--eh-frame-hdr"
16861673
// CHECK-LD-GENTOO-32: "-m" "elf_i386"
@@ -1691,11 +1678,10 @@
16911678
// CHECK-LD-GENTOO-32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
16921679
// CHECK-LD-GENTOO-32: "-lc"
16931680
// CHECK-LD-GENTOO-32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
1694-
// RUN: %clang -### %s -no-pie 2>&1 \
1681+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
16951682
// RUN: --target=x86_64-unknown-linux-gnux32 -rtlib=platform --unwindlib=platform \
16961683
// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
16971684
// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO-X32 %s
1698-
// CHECK-LD-GENTOO-X32-NOT: warning:
16991685
// CHECK-LD-GENTOO-X32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
17001686
// CHECK-LD-GENTOO-X32: "--eh-frame-hdr"
17011687
// CHECK-LD-GENTOO-X32: "-m" "elf32_x86_64"
@@ -1717,11 +1703,10 @@
17171703
// CHECK-LD-RHEL7-DTS: [[SYSROOT]]/usr/lib/gcc/x86_64-redhat-linux/7/../../../../bin/ld
17181704

17191705
// Check whether gcc7 install works fine on Amazon Linux AMI
1720-
// RUN: %clang -### %s -no-pie 2>&1 \
1706+
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
17211707
// RUN: --target=x86_64-amazon-linux -rtlib=libgcc --unwindlib=platform \
17221708
// RUN: --sysroot=%S/Inputs/ami_linux_tree \
17231709
// RUN: | FileCheck --check-prefix=CHECK-LD-AMI %s
1724-
// CHECK-LD-AMI-NOT: warning:
17251710
// CHECK-LD-AMI: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
17261711
// CHECK-LD-AMI: "--eh-frame-hdr"
17271712
// CHECK-LD-AMI: "-m" "elf_x86_64"

0 commit comments

Comments
 (0)