[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Driver / config-file3.c
blob8efe1e555a3c8714a8d186937245c7393b7cfa1c
1 // REQUIRES: shell
2 // REQUIRES: x86-registered-target
4 // RUN: rm -rf %t && mkdir %t
6 //--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by that path.
8 // RUN: mkdir -p %t/workdir/subdir
9 // RUN: echo "@subdir/cfg-s2" > %t/workdir/cfg-1
10 // RUN: echo "-Wundefined-var-template" > %t/workdir/subdir/cfg-s2
12 // RUN: ( cd %t && %clang --config workdir/cfg-1 -c -### %s 2>&1 | FileCheck %s -check-prefix CHECK-REL )
14 // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1
15 // CHECK-REL: -Wundefined-var-template
18 //--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
20 // RUN: mkdir %t/testdmode
21 // RUN: ln -s %clang %t/testdmode/qqq-clang-g++
22 // RUN: echo "-Wundefined-func-template" > %t/testdmode/qqq-clang-g++.cfg
23 // RUN: echo "-Werror" > %t/testdmode/qqq.cfg
24 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix FULL-NAME
26 // FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
27 // FULL-NAME: -Wundefined-func-template
28 // FULL-NAME-NOT: -Werror
30 //--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes.
31 // (As the clang executable and symlink are in different directories, this
32 // requires specifying the path via --config-*-dir= though.)
34 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%t/testdmode -c -### %s 2>&1 | FileCheck %s -check-prefix SYMLINK
36 // SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
38 //--- File specified by --config overrides config inferred from clang executable.
40 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT
42 // CHECK-EXPLICIT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg
44 //--- Invocation qqq-clang-g++ tries to find config file qqq.cfg if qqq-clang-g++.cfg is not found.
46 // RUN: rm %t/testdmode/qqq-clang-g++.cfg
47 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix SHORT-NAME
49 // SHORT-NAME: Configuration file: {{.*}}/testdmode/qqq.cfg
50 // SHORT-NAME: -Werror
51 // SHORT-NAME-NOT: -Wundefined-func-template
54 //--- Config files are searched for in binary directory as well.
56 // RUN: mkdir %t/testbin
57 // RUN: ln -s %clang %t/testbin/clang
58 // RUN: echo "-Werror" > %t/testbin/aaa.cfg
59 // RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN
61 // CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
62 // CHECK-BIN: -Werror
65 //--- If command line contains options that change triple (for instance, -m32), clang tries
66 // reloading config file.
68 //--- When reloading config file, x86_64-clang-g++ tries to find config i386-clang-g++.cfg first.
70 // RUN: mkdir %t/testreload
71 // RUN: ln -s %clang %t/testreload/x86_64-clang-g++
72 // RUN: echo "-Wundefined-func-template" > %t/testreload/i386-clang-g++.cfg
73 // RUN: echo "-Werror" > %t/testreload/i386.cfg
74 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD
76 // CHECK-RELOAD: Configuration file: {{.*}}/testreload/i386-clang-g++.cfg
77 // CHECK-RELOAD: -Wundefined-func-template
78 // CHECK-RELOAD-NOT: -Werror
80 //--- If config file is specified by --config and its name does not start with architecture, it is used without reloading.
82 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -m32 -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1a
84 // CHECK-RELOAD1a: Configuration file: {{.*}}/Inputs/config-3.cfg
86 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c --target=i386 -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1b
88 // CHECK-RELOAD1b: Configuration file: {{.*}}/Inputs/config-3.cfg
90 //--- If config file is specified by --config and its name starts with architecture, it is reloaded.
92 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq -c -m32 -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1c
94 // CHECK-RELOAD1c: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg
96 //--- x86_64-clang-g++ tries to find config i386.cfg if i386-clang-g++.cfg is not found.
98 // RUN: rm %t/testreload/i386-clang-g++.cfg
99 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1d
101 // CHECK-RELOAD1d: Configuration file: {{.*}}/testreload/i386.cfg
102 // CHECK-RELOAD1d: -Werror
103 // CHECK-RELOAD1d-NOT: -Wundefined-func-template