diff options
author | Richard Henderson <rth@redhat.com> | 2016-04-06 11:35:16 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2016-04-06 11:35:16 -0700 |
commit | 64824205cc9312e4e7798cda86a8e4c1f23e5d2b (patch) | |
tree | 7c2cad1cf8de66534953f4d3d802c6e548f0b45a /gcc | |
parent | bc2fc1f3b84472865724b7e91b540ca0fadedd1b (diff) | |
download | gcc-64824205cc9312e4e7798cda86a8e4c1f23e5d2b.zip gcc-64824205cc9312e4e7798cda86a8e4c1f23e5d2b.tar.gz gcc-64824205cc9312e4e7798cda86a8e4c1f23e5d2b.tar.bz2 |
re PR preprocessor/61817 (Inconsistent location of tokens in the expansion list of a built-in macro)
PR preprocessor/61817
PR preprocessor/69391
* internal.h (_cpp_builtin_macro_text): Update decl.
* macro.c (_cpp_builtin_macro_text): Accept location for __LINE__.
(builtin_macro): Accept a second location for __LINE__.
(enter_macro_context): Compute both virtual and real expansion
locations for the macro.
* gcc.dg/pr61817-1.c: New test.
* gcc.dg/pr61817-2.c: New test.
* gcc.dg/pr69391-1.c: New test.
* gcc.dg/pr69391-2.c: New test.
From-SVN: r234794
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr61817-1.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr61817-2.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr69391-1.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr69391-2.c | 12 |
5 files changed, 69 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bc9eed1..0ecced82 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2016-04-06 Richard Henderson <rth@redhat.com> + + * gcc.dg/pr61817-1.c: New test. + * gcc.dg/pr61817-2.c: New test. + * gcc.dg/pr69391-1.c: New test. + * gcc.dg/pr69391-2.c: New test. + 2016-04-06 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/70398 diff --git a/gcc/testsuite/gcc.dg/pr61817-1.c b/gcc/testsuite/gcc.dg/pr61817-1.c new file mode 100644 index 0000000..4230485 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61817-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -ftrack-macro-expansion=0" } */ + +#define A(x) _Static_assert(x, #x) +#define F(x, y, z) a = __LINE__, b = x ## y, c = z + +enum { +#line 10 + F + ( + __LI, + NE__, + __LINE__ + ) +}; + +A(a == 15); +A(b == 15); +A(c == 15); diff --git a/gcc/testsuite/gcc.dg/pr61817-2.c b/gcc/testsuite/gcc.dg/pr61817-2.c new file mode 100644 index 0000000..e4326b8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61817-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -ftrack-macro-expansion=1" } */ + +#define A(x) _Static_assert(x, #x) +#define F(x, y, z) a = __LINE__, b = x ## y, c = z + +enum { +#line 10 + F + ( + __LI, + NE__, + __LINE__ + ) +}; + +A(a == 15); +A(b == 15); +A(c == 15); diff --git a/gcc/testsuite/gcc.dg/pr69391-1.c b/gcc/testsuite/gcc.dg/pr69391-1.c new file mode 100644 index 0000000..15e49dc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr69391-1.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftrack-macro-expansion=0" } */ +#define STR_I(X) #X +#define STR(X) STR_I(X) +#define LINE STR(__LINE__) STR(__LINE__) +int main() +{ + const char *s = LINE; + if (s[0] != '8' || s[1] != '8') + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr69391-2.c b/gcc/testsuite/gcc.dg/pr69391-2.c new file mode 100644 index 0000000..7d2faae --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr69391-2.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftrack-macro-expansion=1" } */ +#define STR_I(X) #X +#define STR(X) STR_I(X) +#define LINE STR(__LINE__) STR(__LINE__) +int main() +{ + const char *s = LINE; + if (s[0] != '8' || s[1] != '8') + __builtin_abort (); + return 0; +} |