| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
|
| 4 |
/// Check that: |
| 5 |
/// - Quoted includes ("...") trigger the diagnostic. |
| 6 |
/// - System headers are ignored. |
| 7 |
/// - #include_next does not cause a duplicate warning. |
| 8 |
// RUN: %clang_cc1 -Wshadow-header -Eonly %t/main.c -I %t/include1 -I %t/include2 \ |
| 9 |
// RUN: -isystem %t/system1 -isystem %t/system2 2>&1 | FileCheck %s --check-prefix=SHADOWING |
| 10 |
|
| 11 |
// SHADOWING: {{.*}} warning: multiple candidates for header 'header.h' found; directory '{{.*}}include1' chosen, ignoring others including '{{.*}}include2' [-Wshadow-header] |
| 12 |
// SHADOWING: warning: include1/header.h included! |
| 13 |
// SHADOWING-NOT: {{.*}} warning: multiple candidates for header 'header.h' found; directory '{{.*}}include2' chosen, ignoring others including '{{.*}}include1' [-Wshadow-header] |
| 14 |
// SHADOWING: warning: include2/header.h included! |
| 15 |
// SHADOWING-NOT: {{.*}} warning: multiple candidates for header 'stdio.h' found; directory '{{.*}}system1' chosen, ignoring others including '{{.*}}system2' [-Wshadow-header] |
| 16 |
// SHADOWING: warning: system1/stdio.h included! |
| 17 |
|
| 18 |
/// Check that the diagnostic is only performed once in MSVC compatibility mode. |
| 19 |
// RUN: %clang_cc1 -fms-compatibility -Wshadow-header -Eonly %t/t.c 2>&1 | FileCheck %s --check-prefix=SHADOWING-MS |
| 20 |
|
| 21 |
// SHADOWING-MS: {{.*}} warning: multiple candidates for header 't3.h' found; directory '{{.*}}foo' chosen, ignoring others including '{{.*}}' [-Wshadow-header] |
| 22 |
// SHADOWING-MS-NOT: {{.*}} warning: multiple candidates for header 't3.h' found; directory '{{.*}}' chosen, ignoring others including '{{.*}}foo' [-Wshadow-header] |
| 23 |
// SHADOWING-MS: warning: Found foo/t3.h. |
| 24 |
|
| 25 |
//--- main.c |
| 26 |
#include "header.h" |
| 27 |
#include <stdio.h> |
| 28 |
|
| 29 |
//--- include1/header.h |
| 30 |
#warning include1/header.h included! |
| 31 |
#include_next "header.h" |
| 32 |
|
| 33 |
//--- include2/header.h |
| 34 |
#warning include2/header.h included! |
| 35 |
|
| 36 |
//--- system1/stdio.h |
| 37 |
#warning system1/stdio.h included! |
| 38 |
|
| 39 |
//--- system2/stdio.h |
| 40 |
#warning system2/stdio.h included! |
| 41 |
|
| 42 |
|
| 43 |
/// Used to test when running in MSVC compatibility |
| 44 |
//--- t.c |
| 45 |
#include "foo/t1.h" |
| 46 |
|
| 47 |
//--- foo/t1.h |
| 48 |
#include "bar/t2.h" |
| 49 |
|
| 50 |
//--- foo/bar/t2.h |
| 51 |
#include "t3.h" |
| 52 |
|
| 53 |
//--- foo/t3.h |
| 54 |
#warning Found foo/t3.h. |
| 55 |
|
| 56 |
//--- t3.h |
| 57 |
#warning Found t3.h. |