re PR c++/64626 (C++14 single quote should not always be a digit separator)
authorEdward Smith-Rowland <3dw4rd@verizon.net>
Tue, 17 Mar 2015 00:50:55 +0000 (00:50 +0000)
committerEdward Smith-Rowland <emsr@gcc.gnu.org>
Tue, 17 Mar 2015 00:50:55 +0000 (00:50 +0000)
libcpp/

2015-03-16  Edward Smith-Rowland  <3dw4rd@verizon.net>

PR c++/64626
* lex.c (lex_number): If a number ends with digit-seps (') skip back
and let lex_string take them.

gcc/testsuite/

2015-03-16  Edward Smith-Rowland  <3dw4rd@verizon.net>

PR c++/64626
g++.dg/cpp1y/pr64626-1.C: New.
g++.dg/cpp1y/pr64626-2.C: New.
g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings.

From-SVN: r221470

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C
gcc/testsuite/g++.dg/cpp1y/pr64626-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/pr64626-2.C [new file with mode: 0644]
libcpp/ChangeLog
libcpp/lex.c

index bf995c79f456ebca1b1f5032a4f8bc2809354a63..c8c54c78819bd9b87730fda2d44a0b0eb4369791 100644 (file)
@@ -1,3 +1,10 @@
+2015-03-16  Edward Smith-Rowland  <3dw4rd@verizon.net>
+
+       PR c++/64626
+       g++.dg/cpp1y/pr64626-1.C: New.
+       g++.dg/cpp1y/pr64626-2.C: New.
+       g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings.
+
 2015-03-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/65427
index 3d4c616ccb1c90e5866758d7d12ff7ac6fae8151..54e5ed19cdccc64010e8023ed82a91a7164e7438 100644 (file)
@@ -10,7 +10,7 @@ main()
   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 "digit separator outside digit sequence" }
+  i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "missing terminating" }
   unsigned u = 0b0001'0000'0000'0000'0000'0000'U; // { dg-error "digit separator outside digit sequence" }
 
   double d = 0.0;
@@ -18,9 +18,13 @@ main()
   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 "digit separator adjacent to exponent" }
+  d = 1.602'176'565e'-19; // { dg-error "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 "digit separator outside digit sequence" }
+  d = 1.602'176'565e-19'; // { dg-error "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 }
+// { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 25 }
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr64626-1.C b/gcc/testsuite/g++.dg/cpp1y/pr64626-1.C
new file mode 100644 (file)
index 0000000..07af9f0
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/64626
+// { dg-do compile { target c++14 } }
+
+#define STR(s) #s
+int
+main()
+{
+  int i = 1'2;
+  const char *s[3]
+  {
+    STR(1' '),
+    STR(..),
+    STR(%:%),
+  };
+}
+#if 0
+1' '
+..
+%:%
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr64626-2.C b/gcc/testsuite/g++.dg/cpp1y/pr64626-2.C
new file mode 100644 (file)
index 0000000..62c3546
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/64626
+// { dg-do compile { target c++14 } }
+
+0''; // { dg-error "empty character constant" }
+
+123'''; // { dg-error "empty character constant" }
+
+// { dg-error "expected unqualified-id" "expected unqualified-id" { target *-*-* } 4 }
+
+// { dg-error "missing terminating" "missing terminating" { target *-*-* } 6 }
+// { dg-error "expected unqualified-id" "expected unqualified-id" { target *-*-* } 6 }
index 2d84835b7b726f1c19bf2c4b11e87bbc4554bc00..c759949528214beaa644f061ed1f9fc9c88cec47 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-16  Edward Smith-Rowland  <3dw4rd@verizon.net>
+
+       PR c++/64626
+       * lex.c (lex_number): If a number ends with digit-seps (') skip back
+       and let lex_string take them.
+
 2015-03-02  Markus Trippelsdorf  <markus@trippelsdorf.de>
 
        PR target/65261
index 0dc473711833ce545b04ebc443ae991ec591477a..bca56299132bfa8ee13025bed4f753837305dbb9 100644 (file)
@@ -1400,6 +1400,9 @@ lex_number (cpp_reader *pfile, cpp_string *number,
          NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur);
          cur++;
        }
+      /* A number can't end with a digit separator.  */
+      while (cur > pfile->buffer->cur && DIGIT_SEP (cur[-1]))
+       --cur;
 
       pfile->buffer->cur = cur;
     }