[PATCH] Postpone __LINE__ evaluation to the end of #line directives
Joseph S. Myers
joseph@codesourcery.com
Wed Nov 27 17:42:00 GMT 2013
On Wed, 27 Nov 2013, mtewoodbury@gmail.com wrote:
> Copyright 2013 assigned to the Free Software Foundation.
FWIW I don't see this in copyright.list yet. If you sent the paperwork
(whether paper mail or scans) to the FSF over a week ago and haven't had
it acknowledged, please chase up assign@gnu.org, and keep chasing them up
weekly until it's acknowledged and a maintainer confirms it's now listed
in copyright.list.
> diff --git a/gcc/testsuite/gcc.dg/cpp/line4.c b/gcc/testsuite/gcc.dg/cpp/line4.c
I think it's best to leave this test as-is and add a new test line9.c
specifically for this case of "#line __LINE__". Changing existing tests
unnecessarily complicates establishing whether a newly seen failure is a
regression or not.
I think it would be worth including tests where the __LINE__ expansion
(which as you note should be the line number of the line *after* the
directive) is involved in concatenation or stringized, e.g.
#define xstr(x) #x
#define str(x) xstr(x)
#line 1 str(__LINE__)
which should set __FILE__ to be the stringized number of the line after
the directive. (I hope these cases will just work given your patch, so
this is just a matter of adding more to the testcase.)
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc-patches
mailing list