File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -887,9 +887,11 @@ void HeaderSearch::DiagnoseHeaderShadowing(
887887 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
888888 bool isAngled, int IncluderLoopIndex, ConstSearchDirIterator MainLoopIt) {
889889
890- if (Diags.isIgnored (diag::warn_header_shadowing, IncludeLoc) || isAngled ||
891- DiagnosedShadowing)
890+ if (Diags.isIgnored (diag::warn_header_shadowing, IncludeLoc) ||
891+ DiagnosedShadowing || (getFileInfo (*FE).DirInfo != SrcMgr::C_User)) {
892+ DiagnosedShadowing = true ;
892893 return ;
894+ }
893895
894896 DiagnosedShadowing = true ;
895897
Original file line number Diff line number Diff line change 33
44/// Check that:
55/// - Quoted includes ("...") trigger the diagnostic.
6- /// - Angled includes (<...>) are ignored.
6+ /// - System headers are ignored.
77/// - #include_next does not cause a duplicate warning.
88// RUN: %clang_cc1 -Wshadow-header -Eonly %t/main.c -I %t/include1 -I %t/include2 \
99// RUN: -isystem %t/system1 -isystem %t/system2 2>&1 | FileCheck %s --check-prefix=SHADOWING
1616// SHADOWING: warning: system1/stdio.h included!
1717
1818/// Check that the diagnostic is only performed once in MSVC compatibility mode.
19- // RUN: %clang_cc1 -fms-compatibility -Wshadow-header -Eonly %t/t.c -I %t -I %t/foo -I %t/foo/bar 2>&1 | FileCheck %s --check-prefix=SHADOWING-MS
19+ // RUN: %clang_cc1 -fms-compatibility -Wshadow-header -Eonly %t/t.c 2>&1 | FileCheck %s --check-prefix=SHADOWING-MS
2020
2121// SHADOWING-MS: {{.*}} warning: multiple candidates for header 't3.h' found; directory '{{.*}}foo' chosen, ignoring '{{.*}}' and others [-Wshadow-header]
22+ // SHADOWING-MS-NOT: {{.*}} warning: multiple candidates for header 't3.h' found; directory '{{.*}}' chosen, ignoring '{{.*}}foo' and others [-Wshadow-header]
2223// SHADOWING-MS: warning: Found foo/t3.h.
23- // SHADOWING-MS-NOT: {{.*}} warning: multiple candidates for header 't3.h' found; directory '{{.*}}foo' chosen, ignoring '{{.*}}' and others [-Wshadow-header]
2424
2525//--- main.c
2626#include "header.h"
You can’t perform that action at this time.
0 commit comments