From: Martin Liska Date: Tue, 10 Jan 2017 14:07:41 +0000 (+0100) Subject: Error for '-' as filename of a precompiled header (PR pch/78970) X-Git-Tag: releases/gcc-5.5.0~599 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db763ca3a9fdafb68de4c247287010a6fd13e6a9;p=thirdparty%2Fgcc.git Error for '-' as filename of a precompiled header (PR pch/78970) 2017-01-10 Martin Liska Backport from mainline 2017-01-05 Martin Liska PR pch/78970 * gcc.c (lookup_compiler): Reject '-' filename for a precompiled header. 2017-01-10 Martin Liska Backport from mainline 2017-01-05 Martin Liska PR pch/78970 * c-opts.c (c_common_post_options): Reject '-' filename for a precompiled header. From-SVN: r244267 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 13ceb88ddce7..31a9231f16e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-01-10 Martin Liska + + Backport from mainline + 2017-01-05 Martin Liska + + PR pch/78970 + * gcc.c (lookup_compiler): Reject '-' filename for a precompiled + header. + 2017-01-10 Chung-Ju Wu Backport from mainline diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 8d5304a36806..2dce6058d6f9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2017-01-10 Martin Liska + + Backport from mainline + 2017-01-05 Martin Liska + + PR pch/78970 + * c-opts.c (c_common_post_options): Reject '-' filename for a precompiled + header. + 2016-07-07 Jakub Jelinek Backported from mainline diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 718a05281a58..ac3976c1387f 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -749,7 +749,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 64d2e34c8608..f3b3f01209c1 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -7911,7 +7911,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;