Home | History | Annotate | Download | only in Lexer
      1 // RUN: %clang_cc1 -fsyntax-only -Wno-header-guard %s
      2 // RUN: %clang_cc1 -fsyntax-only -Wheader-guard %s 2>&1 | FileCheck %s
      3 
      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 
     10 #include "Inputs/bad-header-guard.h"
     11 // CHECK: In file included from {{.*}}header.cpp:{{[0-9]*}}:
     12 // 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
     13 // CHECK: {{^}}#ifndef bad_header_guard
     14 // CHECK: {{^}}        ^~~~~~~~~~~~~~~~
     15 // CHECK: {{.*}}bad-header-guard.h:2:9: note: 'bad_guard' is defined here; did you mean 'bad_header_guard'?
     16 // CHECK: {{^}}#define bad_guard
     17 // CHECK: {{^}}        ^~~~~~~~~
     18 // CHECK: {{^}}        bad_header_guard
     19 
     20 #include "Inputs/bad-header-guard-defined.h"
     21 // CHECK: In file included from {{.*}}header.cpp:{{[0-9]*}}:
     22 // CHECK: {{.*}}bad-header-guard-defined.h:1:2: warning: 'foo' is used as a header guard here, followed by #define of a different macro
     23 // CHECK: {{^}}#if !defined(foo)
     24 // CHECK: {{^}} ^~
     25 // CHECK: {{.*}}bad-header-guard-defined.h:2:9: note: 'goo' is defined here; did you mean 'foo'?
     26 // CHECK: {{^}}#define goo
     27 // CHECK: {{^}}        ^~~
     28 // CHECK: {{^}}        foo
     29 
     30 #include "Inputs/multiple.h"
     31 #include "Inputs/multiple.h"
     32 #include "Inputs/multiple.h"
     33 #include "Inputs/multiple.h"
     34 // CHECK: In file included from {{.*}}header.cpp:{{[0-9]*}}:
     35 // CHECK: {{.*}}multiple.h:1:9: warning: 'multiple' is used as a header guard here, followed by #define of a different macro
     36 // CHECK: {{^}}#ifndef multiple
     37 // CHECK: {{^}}        ^~~~~~~~
     38 // CHECK: {{.*}}multiple.h:2:9: note: 'multi' is defined here; did you mean 'multiple'?
     39 // CHECK: {{^}}#define multi
     40 // CHECK: {{^}}        ^~~~~
     41 // CHECK: {{^}}        multiple
     42 
     43 // CHECK: 3 warnings generated.
     44