From: Richard Biener Date: Wed, 11 Feb 2015 12:14:54 +0000 (+0000) Subject: backport: re PR c/57653 (filename information discarded when using -imacros) X-Git-Tag: releases/gcc-4.8.5~278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1fd276e9d4c0dee92eed30dadbaa50dde8eb55b;p=thirdparty%2Fgcc.git backport: re PR c/57653 (filename information discarded when using -imacros) 2015-02-11 Richard Biener Backport from mainline 2014-07-24 Marek Polacek PR c/57653 * c-opts.c (c_finish_options): If -imacros is in effect, return. * c-c++-common/pr57653.c: New test. * c-c++-common/pr57653.h: New file. * c-c++-common/pr57653-2.c: New test. * c-c++-common/pr57653-2.h: New file. From-SVN: r220615 --- diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 5ee7024efa9f..30de1e113bee 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1347,6 +1347,12 @@ c_finish_options (void) static void push_command_line_include (void) { + /* This can happen if disabled by -imacros for example. + Punt so that we don't set "" as the filename for + the header. */ + if (include_cursor > deferred_count) + return; + if (!done_preinclude) { done_preinclude = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a3d4b249ddd6..f20e49897b5a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2015-02-11 Richard Biener + + Backport from mainline + 2014-07-24 Marek Polacek + + PR c/57653 + * c-c++-common/pr57653.c: New test. + * c-c++-common/pr57653.h: New file. + * c-c++-common/pr57653-2.c: New test. + * c-c++-common/pr57653-2.h: New file. + 2015-02-04 Uros Bizjak Backport from mainline diff --git a/gcc/testsuite/c-c++-common/pr57653-2.c b/gcc/testsuite/c-c++-common/pr57653-2.c new file mode 100644 index 000000000000..086f6be5ce15 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr57653-2.c @@ -0,0 +1,4 @@ +/* { dg-do preprocess } */ +/* { dg-options "-imacros ${srcdir}/c-c++-common/pr57653-2.h" } */ + +/* Empty. */ diff --git a/gcc/testsuite/c-c++-common/pr57653-2.h b/gcc/testsuite/c-c++-common/pr57653-2.h new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr57653-2.h @@ -0,0 +1 @@ + diff --git a/gcc/testsuite/c-c++-common/pr57653.c b/gcc/testsuite/c-c++-common/pr57653.c new file mode 100644 index 000000000000..620471e24194 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr57653.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-imacros ${srcdir}/c-c++-common/pr57653.h" } */ + +__attribute__((used)) static const char s[] = F; + +/* { dg-final { scan-assembler-not "command-line" } } */ diff --git a/gcc/testsuite/c-c++-common/pr57653.h b/gcc/testsuite/c-c++-common/pr57653.h new file mode 100644 index 000000000000..5a93388e9fd5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr57653.h @@ -0,0 +1 @@ +#define F __FILE__