When non-modular headers are imported while not building a module but
in -fmodules mode, be conservative and preserve the default #import
semantic: do not reenter headers.
rdar://problem/
33745031
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310605
91177308-0d34-0410-b5e6-
96231b3b80d8
// headers find in the wild might rely only on #import and do not contain
// controlling macros, be conservative and only try to enter textual headers
// if such macro is present.
- if (!FileInfo.isModuleHeader &&
+ if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
FileInfo.getControllingMacro(ExternalLookup))
TryEnterHdr = true;
return TryEnterHdr;
--- /dev/null
+#ifndef RANDOM_DEP
+
+@interface X
+@end
+
+#endif // RANDOM_DEP
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
+
+// expected-no-diagnostics
+
+#import "x.h"
+#import "x.h"
+