diff mbox

[obvious,c-family] Fix column location in c_lex_with_flags errors

Message ID CAESRpQChxg3ycAK0Peq0spi-pKLgTJartR8Luj98QKMjH2AKaA@mail.gmail.com
State New
Headers show

Commit Message

Manuel López-Ibáñez Aug. 22, 2015, 12:46 p.m. UTC
input_location is not always up-to-date in the preprocessor. Using the
actual token's location is always best. Bootstrapped & regtested  on
x86-64-linux-gnu & committed as obvious https://gcc.gnu.org/r227096

Cheers,

Manuel.

Fix column location in c_lex_with_flags errors

gcc/testsuite/ChangeLog:

2015-08-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>

        * gcc.dg/cpp/multiline-2.c: Add column numbers.
        * gcc.dg/dollar.c: Likewise.
        * gcc.dg/pragma-message.c: Likewise.
        * g++.dg/cpp1y/digit-sep-neg.C: Likewise.
        * c-c++-common/raw-string-14.c: Likewise.

gcc/c-family/ChangeLog:

2015-08-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>

        * c-lex.c (c_lex_with_flags): Use explicit locations.

Comments

Jason Merrill Aug. 22, 2015, 1:55 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: gcc/c-family/c-lex.c
===================================================================
--- gcc/c-family/c-lex.c	(revision 226953)
+++ gcc/c-family/c-lex.c	(working copy)
@@ -521,15 +521,15 @@  c_lex_with_flags (tree *value, location_
     case CPP_OTHER:
       {
 	cppchar_t c = tok->val.str.text[0];
 
 	if (c == '"' || c == '\'')
-	  error ("missing terminating %c character", (int) c);
+	  error_at (*loc, "missing terminating %c character", (int) c);
 	else if (ISGRAPH (c))
-	  error ("stray %qc in program", (int) c);
+	  error_at (*loc, "stray %qc in program", (int) c);
 	else
-	  error ("stray %<\\%o%> in program", (int) c);
+	  error_at (*loc, "stray %<\\%o%> in program", (int) c);
       }
       goto retry;
 
     case CPP_CHAR_USERDEF:
     case CPP_WCHAR_USERDEF:
Index: gcc/testsuite/gcc.dg/cpp/multiline-2.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/multiline-2.c	(revision 226953)
+++ gcc/testsuite/gcc.dg/cpp/multiline-2.c	(working copy)
@@ -7,8 +7,8 @@ 
 
 const char *p = "line 1
 "
 "";			      /* The compiler front end sees this.  */
 
-/* { dg-error "missing term" "multiline strings" { target *-*-* } 8 } */
+/* { dg-error "17:missing term" "multiline strings" { target *-*-* } 8 } */
 /* { dg-error "missing term" "multiline strings" { target *-*-* } 9 } */
 
Index: gcc/testsuite/gcc.dg/dollar.c
===================================================================
--- gcc/testsuite/gcc.dg/dollar.c	(revision 226953)
+++ gcc/testsuite/gcc.dg/dollar.c	(working copy)
@@ -4,6 +4,6 @@ 
 /* { dg-options -fno-dollars-in-identifiers } */
 
 /* Test that -fno-dollars-in-identifiers is honoured.
    Neil Booth, 17 May 2003.  */
 
-int foobar$;	/* { dg-error "stray '\\$'" } */
+int foobar$;	/* { dg-error "11:stray '\\$'" } */
Index: gcc/testsuite/gcc.dg/pragma-message.c
===================================================================
--- gcc/testsuite/gcc.dg/pragma-message.c	(revision 226953)
+++ gcc/testsuite/gcc.dg/pragma-message.c	(working copy)
@@ -14,17 +14,17 @@ 
    then 'note: #pragma message: ', allowing dg-message to check output.
    If unexpected pragma messages are printed (anything not caught by a
    matching dg-message), dejagnu will report these as excess errors.  */
 
 #pragma message "
-/* { dg-error "missing terminating" "" { target *-*-* } 18 } */
+/* { dg-error "17:missing terminating" "" { target *-*-* } 18 } */
 /* { dg-warning "expected a string" "" { target *-*-* } 18 } */
 #pragma message "Bad 1
-/* { dg-error "missing terminating" "" { target *-*-* } 21 } */
+/* { dg-error "17:missing terminating" "" { target *-*-* } 21 } */
 /* { dg-warning "expected a string" "" { target *-*-* } 21 } */
 #pragma message ("Bad 2
-/* { dg-error "missing terminating" "" { target *-*-* } 24 } */
+/* { dg-error "18:missing terminating" "" { target *-*-* } 24 } */
 /* { dg-warning "expected a string" "" { target *-*-* } 24 } */
 #pragma message ("Bad 3"
 /* { dg-warning "malformed '#pragma message" "" { target *-*-* } 27 } */
 
 #pragma message "" junk
Index: gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C	(revision 226953)
+++ gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C	(working copy)
@@ -8,22 +8,22 @@  main()
   i = 0X'100000; // { dg-error "digit separator after base indicator" }
   i = 0x'100000; // { dg-error "digit separator after base indicator" }
   i = 0004''000'000; // { dg-error "adjacent digit separators" }
   i = 0B1'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0; // OK
   i = 0b'0001'0000'0000'0000'0000'0000; // { dg-error "digit separator after base indicator" }
-  i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "missing terminating" }
+  i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "38:missing terminating" }
   unsigned u = 0b0001'0000'0000'0000'0000'0000'U; // { dg-error "digit separator outside digit sequence" }
 
   double d = 0.0;
   d = 1'.602'176'565e-19; // { dg-error "digit separator adjacent to decimal point" }
   d = 1.'602'176'565e-19; // { dg-error "digit separator adjacent to decimal point" }
   d = 1.602''176'565e-19; // { dg-error "adjacent digit separators" }
   d = 1.602'176'565'e-19; // { dg-error "digit separator adjacent to exponent" }
-  d = 1.602'176'565e'-19; // { dg-error "missing terminating" }
+  d = 1.602'176'565e'-19; // { dg-error "21:missing terminating" }
   d = 1.602'176'565e-'19; // { dg-error "digit separator adjacent to exponent" }
   d = 1.602'176'565e-1'9; // OK
-  d = 1.602'176'565e-19'; // { dg-error "missing terminating" }
+  d = 1.602'176'565e-19'; // { dg-error "24:missing terminating" }
   float f = 1.602'176'565e-19'F; // { dg-error "digit separator outside digit sequence" }
 }
 
 // { dg-error "exponent has no digits" "exponent has no digits" { target *-*-* } 21 }
 // { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 14 }
Index: gcc/testsuite/c-c++-common/raw-string-14.c
===================================================================
--- gcc/testsuite/c-c++-common/raw-string-14.c	(revision 226953)
+++ gcc/testsuite/c-c++-common/raw-string-14.c	(working copy)
@@ -10,11 +10,11 @@  def()abcdef";
 const void *s1 = R"??/
 ()??/";
 	// { dg-error "invalid new-line" "invalid" { target *-*-* } 10 }
 	// { dg-error "stray" "stray" { target *-*-* } 10 }
 	// { dg-warning "missing terminating" "missing" { target *-*-* } 10 }
-	// { dg-error "missing terminating" "missing" { target *-*-* } 10 }
+	// { dg-error "19:missing terminating" "missing" { target *-*-* } 10 }
 const void *s2 = R"abcdefghijklmn??/(a)abcdefghijklmn???";
 	// { dg-error "raw string delimiter longer" "longer" { target *-*-* } 16 }
 	// { dg-error "stray" "stray" { target *-*-* } 16 }
 	// { dg-error "expected" "expected" { target *-*-* } 16 }
 const void *s3 = R"abcdefghijklmno??/(a)abcdefghijklmno???";