From: Reid Kleckner Date: Fri, 9 Aug 2019 19:49:14 +0000 (+0000) Subject: Don't diagnose errors when a file matches an include component X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5264f163e21c3304450b36d1bc10a8c2f4a41aef;p=clang Don't diagnose errors when a file matches an include component This regressed in r368322, and was reported as PR42948 and on the mailing list. The fix is to ignore the specific error code for this case. The problem doesn't seem to reproduce on Windows, where a different error code is used instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368475 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 8b6a19e080..e9542b8d16 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -316,7 +316,8 @@ const FileEntry *HeaderSearch::getFileAndSuggestModule( // message. std::error_code EC = File.getError(); if (EC != std::errc::no_such_file_or_directory && - EC != std::errc::invalid_argument && EC != std::errc::is_a_directory) { + EC != std::errc::invalid_argument && EC != std::errc::is_a_directory && + EC != std::errc::not_a_directory) { Diags.Report(IncludeLoc, diag::err_cannot_open_file) << FileName << EC.message(); } diff --git a/test/Preprocessor/Inputs/include-file-and-dir/file-and-dir b/test/Preprocessor/Inputs/include-file-and-dir/file-and-dir new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Preprocessor/Inputs/include-file-and-dir/incdir/file-and-dir/foo.h b/test/Preprocessor/Inputs/include-file-and-dir/incdir/file-and-dir/foo.h new file mode 100644 index 0000000000..9d3235e89d --- /dev/null +++ b/test/Preprocessor/Inputs/include-file-and-dir/incdir/file-and-dir/foo.h @@ -0,0 +1 @@ +included_foo_dot_h diff --git a/test/Preprocessor/include-header-file-and-dir.c b/test/Preprocessor/include-header-file-and-dir.c new file mode 100644 index 0000000000..8da95ce9b5 --- /dev/null +++ b/test/Preprocessor/include-header-file-and-dir.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -E -P %s -I%S/Inputs/include-file-and-dir -I%S/Inputs/include-file-and-dir/incdir -o - | FileCheck %s +#include "file-and-dir/foo.h" + +// CHECK: included_foo_dot_h