@@ -1174,6 +1174,9 @@ c_common_post_options (const char **pfilename)
"the %qs debug info cannot be used with "
"pre-compiled headers",
debug_set_names (write_symbols & ~DWARF2_DEBUG));
+ /* Let libcpp know that the main file is a header so it won't
+ complain about things like #include_next and #pragma once. */
+ cpp_opts->main_search = CMS_header;
}
else if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
c_common_no_more_pch ();
new file mode 100644
@@ -0,0 +1,7 @@
+/* PR pch/9471 */
+/* PR pch/47857 */
+/* Test will fail if any warnings get issued while compiling the header into a PCH. */
+#include "main-file-warnings.H"
+#pragma once /* { dg-warning "in main file" } */
+#pragma GCC system_header /* { dg-warning "outside include file" } */
+#include_next <stdint.h> /* { dg-warning "in primary source file" } */
new file mode 100644
@@ -0,0 +1,3 @@
+#pragma once /* { dg-bogus "in main file" } */
+#pragma GCC system_header /* { dg-bogus "outside include file" } */
+#include_next <stdint.h> /* { dg-bogus "in primary source file" } */
new file mode 100644
@@ -0,0 +1,7 @@
+/* PR pch/9471 */
+/* PR pch/47857 */
+/* Test will fail if any warnings get issued while compiling the header into a PCH. */
+#include "main-file-warnings.h"
+#pragma once /* { dg-warning "in main file" } */
+#pragma GCC system_header /* { dg-warning "outside include file" } */
+#include_next <stdint.h> /* { dg-warning "in primary source file" } */
new file mode 100644
@@ -0,0 +1,3 @@
+#pragma once /* { dg-bogus "in main file" } */
+#pragma GCC system_header /* { dg-bogus "outside include file" } */
+#include_next <stdint.h> /* { dg-bogus "in primary source file" } */