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