From cd445b543ce675338249055ee7493cc54777307a Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 5 Jan 2017 15:17:07 +0100 Subject: [PATCH] Error for '-' as filename of a precompiled header (PR pch/78970) 2017-01-05 Martin Liska PR pch/78970 * c-opts.c (c_common_post_options): Reject '-' filename for a precompiled header. 2017-01-05 Martin Liska PR pch/78970 * gcc.c (lookup_compiler): Reject '-' filename for a precompiled header. From-SVN: r244103 --- gcc/ChangeLog | 6 ++++++ gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-opts.c | 7 ++++++- gcc/gcc.c | 11 ++++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cccfd7d49f5..28b46e49db0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-01-05 Martin Liska + + PR pch/78970 + * gcc.c (lookup_compiler): Reject '-' filename for a precompiled + header. + 2017-01-05 Andreas Krebbel * config/s390/s390.c (s390_expand_setmem): Unroll the loop for diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index b9bb5fe59a3..7ec36dcbb7d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-01-05 Martin Liska + + PR pch/78970 + * c-opts.c (c_common_post_options): Reject '-' filename for a precompiled + header. + 2017-01-04 Marek Polacek PR c++/64767 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 14e038c02b3..7dea1657409 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -744,7 +744,12 @@ c_common_post_options (const char **pfilename) in_fnames[0] = ""; } else if (strcmp (in_fnames[0], "-") == 0) - in_fnames[0] = ""; + { + if (pch_file) + error ("cannot use %<-%> as input filename for a precompiled header"); + + in_fnames[0] = ""; + } if (out_fname == NULL || !strcmp (out_fname, "-")) out_fname = ""; diff --git a/gcc/gcc.c b/gcc/gcc.c index 8154953eb1d..1d2ed99ef5f 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -8325,7 +8325,16 @@ lookup_compiler (const char *name, size_t length, const char *language) { for (cp = compilers + n_compilers - 1; cp >= compilers; cp--) if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language)) - return cp; + { + if (name != NULL && strcmp (name, "-") == 0 + && (strcmp (cp->suffix, "@c-header") == 0 + || strcmp (cp->suffix, "@c++-header") == 0)) + fatal_error (input_location, + "cannot use %<-%> as input filename for a " + "precompiled header"); + + return cp; + } error ("language %s not recognized", language); return 0; -- 2.30.2