--- /dev/null
+/* PR preprocessor/80753 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+#if __has_include("nonexistent.h")
+# error
+#endif
+
+#include "nonexistent.h"
+
+/* { dg-message "nonexistent.h" "nonexistent.h" { target *-*-* } 0 } */
+/* { dg-message "terminated" "terminated" { target *-*-* } 0 } */
+
+/* This declaration should not receive any diagnostic. */
+foo bar;
/* If this file is implicitly preincluded. */
bool implicit_preinclude : 1;
+ /* Set if a header wasn't found with __has_include or __has_include_next
+ and error should be emitted if it is included normally. */
+ bool deferred_error : 1;
+
/* > 0: Known C++ Module header unit, <0: known not. ==0, unknown */
int header_unit : 2;
};
cpp_file_hash_entry *entry
= search_cache ((struct cpp_file_hash_entry *) *hash_slot, start_dir);
if (entry)
- return entry->u.file;
+ {
+ if (entry->u.file->deferred_error && kind == _cpp_FFK_NORMAL)
+ {
+ open_file_failed (pfile, entry->u.file, angle_brackets, loc);
+ entry->u.file->deferred_error = false;
+ }
+ return entry->u.file;
+ }
_cpp_file *file = make_cpp_file (start_dir, fname);
file->implicit_preinclude
if (kind != _cpp_FFK_HAS_INCLUDE)
open_file_failed (pfile, file, angle_brackets, loc);
+ else
+ file->deferred_error = true;
break;
}