PR preprocessor/39646
* include/line-map.h (enum lc_reason): Add LC_RENAME_VERBATIM.
* line-map.c (linemap_add): Handle LC_RENAME_VERBATIM.
* directives.c (do_line, do_linemarker): Use LC_RENAME_VERBATIM in
place of LC_RENAME.
gcc/testsuite:
* gcc.dg/cpp/line8.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146319
138bc75d-0d04-0410-961f-
82ee72b054a4
2009-04-18 Joseph Myers <joseph@codesourcery.com>
+ PR preprocessor/39646
+ * gcc.dg/cpp/line8.c: New test.
+
+2009-04-18 Joseph Myers <joseph@codesourcery.com>
+
PR preprocessor/39647
* gcc.dg/cpp/line7.c: New test.
--- /dev/null
+/* Test that "" is not specially interpreted as "<stdin>" in a #line
+ directive. PR 39646. */
+
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+extern int x;
+
+#line 24 ""
+extern char z[sizeof __FILE__ == 1];
2009-04-18 Joseph Myers <joseph@codesourcery.com>
+ PR preprocessor/39646
+ * include/line-map.h (enum lc_reason): Add LC_RENAME_VERBATIM.
+ * line-map.c (linemap_add): Handle LC_RENAME_VERBATIM.
+ * directives.c (do_line, do_linemarker): Use LC_RENAME_VERBATIM in
+ place of LC_RENAME.
+
+2009-04-18 Joseph Myers <joseph@codesourcery.com>
+
PR preprocessor/39647
* directives.c (check_eol): Add parameter expand.
(do_undef, parse_include, do_line, do_linemarker, do_ident,
}
skip_rest_of_line (pfile);
- _cpp_do_file_change (pfile, LC_RENAME, new_file, new_lineno,
+ _cpp_do_file_change (pfile, LC_RENAME_VERBATIM, new_file, new_lineno,
map_sysp);
}
const char *new_file = map->to_file;
linenum_type new_lineno;
unsigned int new_sysp = map->sysp;
- enum lc_reason reason = LC_RENAME;
+ enum lc_reason reason = LC_RENAME_VERBATIM;
int flag;
bool wrapped;
when including a new file, e.g. a #include directive in C.
LC_LEAVE is when reaching a file's end. LC_RENAME is when a file
name or line number changes for neither of the above reasons
- (e.g. a #line directive in C). */
-enum lc_reason {LC_ENTER = 0, LC_LEAVE, LC_RENAME};
+ (e.g. a #line directive in C); LC_RENAME_VERBATIM is like LC_RENAME
+ but a filename of "" is not specially interpreted as standard input. */
+enum lc_reason {LC_ENTER = 0, LC_LEAVE, LC_RENAME, LC_RENAME_VERBATIM};
/* The type of line numbers. */
typedef unsigned int linenum_type;
map = &set->maps[set->used];
- if (to_file && *to_file == '\0')
+ if (to_file && *to_file == '\0' && reason != LC_RENAME_VERBATIM)
to_file = "<stdin>";
+ if (reason == LC_RENAME_VERBATIM)
+ reason = LC_RENAME;
+
/* If we don't keep our line maps consistent, we can easily
segfault. Don't rely on the client to do it for us. */
if (set->depth == 0)