#endif /* #if CHECKING_P */
/* Attempt to locate a suitable location within FILE for a
- #include directive to be inserted before. FILE should
- be a string from libcpp (pointer equality is used).
+ #include directive to be inserted before.
LOC is the location of the relevant diagnostic.
Attempt to return the location within FILE immediately
if (const line_map_ordinary *from
= linemap_included_from_linemap (line_table, ord_map))
- if (from->to_file == file)
+ /* We cannot use pointer equality, because with preprocessed
+ input all filename strings are unique. */
+ if (0 == strcmp (from->to_file, file))
{
last_include_ord_map = from;
last_ord_map_after_include = NULL;
}
- if (ord_map->to_file == file)
+ /* Likewise, use strcmp, and reject any line-zero introductory
+ map. */
+ if (ord_map->to_line && 0 == strcmp (ord_map->to_file, file))
{
if (!first_ord_map_in_file)
first_ord_map_in_file = ord_map;
--- /dev/null
+// { dg-do compile }
+// { dg-additional-options -fdiagnostics-show-caret }
+// comment
+
+
+
+
+
+
+// Intentional blank lines
+
+
+
+
+
+
+
+
+#include "missing-std-include-10.h"
+// HERE
+
+
+
+
+
+
+// Intentional blank lines
+
+
+
+
+
+
+
+
+
+int main ()
+{
+ return strcmp ("", "");
+}
+// { dg-additional-files "missing-std-include-10.h" }
+// { dg-regexp {[^\n]*: error: 'strcmp' was not declared in this scope\n *return strcmp [^\n]*;\n *\^~*\n} }
+// { dg-regexp {[^\n]* note: 'strcmp' is defined in header[^\n]*\n #include "missing-std-include-10.h"\n\+#include <cstring>\n // HERE\n} }
--- /dev/null
+// { dg-do compile }
+// { dg-additional-options {-fdiagnostics-show-caret -save-temps} }
+// comment save-temps causes us to compile preprocessed output
+
+
+
+
+
+
+// Intentional blank lines
+
+
+
+
+
+
+
+
+#include "missing-std-include-10.h"
+// HERE
+
+
+
+
+
+
+// Intentional blank lines
+
+
+
+
+
+
+
+
+
+int main ()
+{
+ return strcmp ("", "");
+}
+// { dg-additional-files "missing-std-include-10.h" }
+// { dg-regexp {[^\n]*: error: 'strcmp' was not declared in this scope\n *return strcmp [^\n]*;\n *\^~*\n} }
+// { dg-regexp {[^\n]* note: 'strcmp' is defined in header[^\n]*\n #include "missing-std-include-10.h"\n\+#include <cstring>\n // HERE\n} }