]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cpphash.c (special_symbol): When expanding __LINE__, use the top file buffer, not...
authorZack Weinberg <zack@rabi.columbia.edu>
Fri, 9 Apr 1999 20:02:39 +0000 (20:02 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Fri, 9 Apr 1999 20:02:39 +0000 (20:02 +0000)
1999-04-09 22:58 -0400  Zack Weinberg  <zack@rabi.columbia.edu>
* cpphash.c (special_symbol): When expanding __LINE__, use the
top file buffer, not the top buffer.

From-SVN: r26319

gcc/ChangeLog
gcc/cpphash.c
gcc/testsuite/gcc.dg/990409-1.c [new file with mode: 0644]

index 31196d8f3df0a56dff05043bdf0790c2cd37ed27..12b0d4d0ecd3a6daba08326a3f342f75058010be 100644 (file)
@@ -1,3 +1,8 @@
+1999-04-09 22:58 -0400  Zack Weinberg  <zack@rabi.columbia.edu>
+
+       * cpphash.c (special_symbol): When expanding __LINE__, use the
+       top file buffer, not the top buffer.
+
 Fri Apr  9 13:41:04 1999  Jim Wilson  <wilson@cygnus.com>
 
        * Makefile.in (check-g++, check-gcc, check-g77, check-objc): Add
index 87946f2524ba595111ec169dd61d8ac0556ea3ad..5c2d5f3d800b86a052a97e3ef9c1e69f16a17820 100644 (file)
@@ -991,7 +991,7 @@ special_symbol (hp, pfile)
     case T_SPECLINE:
       {
        long line;
-       cpp_buf_line_and_col (CPP_BUFFER (pfile), &line, NULL);
+       cpp_buf_line_and_col (cpp_file_buffer (pfile), &line, NULL);
 
        CPP_RESERVE (pfile, 10);
        sprintf (CPP_PWRITTEN (pfile), "%ld", line);
diff --git a/gcc/testsuite/gcc.dg/990409-1.c b/gcc/testsuite/gcc.dg/990409-1.c
new file mode 100644 (file)
index 0000000..faa37e0
--- /dev/null
@@ -0,0 +1,18 @@
+/* Test that __LINE__ works when embedded in a macro. */
+/* { dg-do run } */
+
+#define foo() bar(__LINE__)
+
+void
+bar(int x)
+{
+    if (x != 16)
+       abort();
+}
+
+int
+main(void)
+{
+    foo();    /* This is line 16 */
+    return 0;
+}