[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Lexer / header.cpp
blobf02b1e69db439b1c03c442d1444e28fde5ab0b9b
1 // RUN: %clang_cc1 -fsyntax-only -Wno-header-guard %s
2 // RUN: %clang_cc1 -fsyntax-only -Wheader-guard %s 2>&1 | FileCheck %s
4 #include "Inputs/good-header-guard.h"
5 #include "Inputs/no-define.h"
6 #include "Inputs/different-define.h"
7 #include "Inputs/out-of-order-define.h"
8 #include "Inputs/tokens-between-ifndef-and-define.h"
9 #include "Inputs/unlikely-to-be-header-guard.h"
11 #include "Inputs/bad-header-guard.h"
12 // CHECK: In file included from {{.*}}header.cpp:{{[0-9]*}}:
13 // CHECK: {{.*}}bad-header-guard.h:1:9: warning: 'bad_header_guard' is used as a header guard here, followed by #define of a different macro
14 // CHECK: {{^}}#ifndef bad_header_guard
15 // CHECK: {{^}} ^~~~~~~~~~~~~~~~
16 // CHECK: {{.*}}bad-header-guard.h:2:9: note: 'bad_guard' is defined here; did you mean 'bad_header_guard'?
17 // CHECK: {{^}}#define bad_guard
18 // CHECK: {{^}} ^~~~~~~~~
19 // CHECK: {{^}} bad_header_guard
21 #include "Inputs/bad-header-guard-defined.h"
22 // CHECK: In file included from {{.*}}header.cpp:{{[0-9]*}}:
23 // CHECK: {{.*}}bad-header-guard-defined.h:1:2: warning: 'foo' is used as a header guard here, followed by #define of a different macro
24 // CHECK: {{^}}#if !defined(foo)
25 // CHECK: {{^}} ^~
26 // CHECK: {{.*}}bad-header-guard-defined.h:2:9: note: 'goo' is defined here; did you mean 'foo'?
27 // CHECK: {{^}}#define goo
28 // CHECK: {{^}} ^~~
29 // CHECK: {{^}} foo
31 #include "Inputs/multiple.h"
32 #include "Inputs/multiple.h"
33 #include "Inputs/multiple.h"
34 #include "Inputs/multiple.h"
35 // CHECK: In file included from {{.*}}header.cpp:{{[0-9]*}}:
36 // CHECK: {{.*}}multiple.h:1:9: warning: 'multiple' is used as a header guard here, followed by #define of a different macro
37 // CHECK: {{^}}#ifndef multiple
38 // CHECK: {{^}} ^~~~~~~~
39 // CHECK: {{.*}}multiple.h:2:9: note: 'multi' is defined here; did you mean 'multiple'?
40 // CHECK: {{^}}#define multi
41 // CHECK: {{^}} ^~~~~
42 // CHECK: {{^}} multiple
44 // CHECK: 3 warnings generated.