@@ -1001,7 +1001,7 @@ interpret_float (const cpp_token *token, unsigned int flags,
}
copy = (char *) alloca (copylen + 1);
- if (cxx_dialect > cxx11)
+ if (c_dialect_cxx () ? cxx_dialect > cxx11 : flag_isoc2x)
{
size_t maxlen = 0;
for (size_t i = 0; i < copylen; ++i)
new file mode 100644
@@ -0,0 +1,7 @@
+/* Test C2x digit separators not in C11. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+#define m(x) 0
+
+_Static_assert (m(1'2)+(3'4) == 0, "digit separators");
new file mode 100644
@@ -0,0 +1,39 @@
+/* Test C2x digit separators. Valid usages. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+_Static_assert (123'45'6 == 123456);
+_Static_assert (0'123 == 0123);
+_Static_assert (0x1'23 == 0x123);
+
+#define m(x) 0
+
+_Static_assert (m(1'2)+(3'4) == 34);
+
+_Static_assert (0x0'e-0xe == 0);
+
+#define a0 '.' -
+#define acat(x) a ## x
+_Static_assert (acat (0'.') == 0);
+
+#define c0(x) 0
+#define b0 c0 (
+#define bcat(x) b ## x
+_Static_assert (bcat (0'\u00c0')) == 0);
+
+extern void exit (int);
+extern void abort (void);
+
+int
+main (void)
+{
+ if (314'159e-0'5f != 3.14159f)
+ abort ();
+ exit (0);
+}
+
+#line 0'123
+_Static_assert (__LINE__ == 123);
+
+#line 4'56'7'8'9
+_Static_assert (__LINE__ == 456789);
new file mode 100644
@@ -0,0 +1,25 @@
+/* Test C2x digit separators. Invalid usages. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+void
+tf (void)
+{
+ int i;
+ i = 1''2; /* { dg-error "adjacent digit separators" } */
+ i = 0x'0; /* { dg-error "digit separator after base indicator" } */
+ i = 0X'1; /* { dg-error "digit separator after base indicator" } */
+ i = 0b'0; /* { dg-error "digit separator after base indicator" } */
+ i = 0B'1; /* { dg-error "digit separator after base indicator" } */
+ i = 1'u; /* { dg-error "digit separator outside digit sequence" } */
+ float f = 1.2e-3'f; /* { dg-error "digit separator outside digit sequence" } */
+ i = 1'2'3'; /* { dg-error "12:missing terminating" } */
+ ;
+ double d;
+ d = 1'.2'3e-4; /* { dg-warning "multi-character" } */
+ /* { dg-error "expected" "parse error" { target *-*-* } .-1 } */
+ d = 1.2''3; /* { dg-error "adjacent digit separators" } */
+ d = 1.23e-4''5; /* { dg-error "adjacent digit separators" } */
+ d = 1.2'3e-4'5'; /* { dg-error "17:missing terminating" } */
+ /* { dg-error "expected" "parse error" { target *-*-* } .-1 } */
+}
@@ -103,13 +103,13 @@ static const struct lang_flags lang_defaults[] =
/* GNUC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0 },
/* GNUC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0 },
/* GNUC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0 },
- /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0 },
+ /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0 },
/* STDC89 */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
/* STDC94 */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
/* STDC99 */ { 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
/* STDC11 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
/* STDC17 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
- /* STDC2X */ { 1, 0, 1, 1, 1, 1,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