* [committed] preprocessor: Disable trigraphs for C2x
@ 2022-09-05 22:06 Joseph Myers
0 siblings, 0 replies; only message in thread
From: Joseph Myers @ 2022-09-05 22:06 UTC (permalink / raw)
To: gcc-patches
ISO C2x removes trigraphs, so disable them accordingly for -std=c2x
(they can still be enabled using -trigraphs).
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
libcpp/
* init.cc (lang_defaults): Disable trigraphs for C2x.
gcc/testsuite/
* gcc.dg/cpp/c11-trigraphs-1.c, gcc.dg/cpp/c2x-trigraphs-1.c,
gcc.dg/cpp/c2x-trigraphs-2.c: New tests.
diff --git a/gcc/testsuite/gcc.dg/cpp/c11-trigraphs-1.c b/gcc/testsuite/gcc.dg/cpp/c11-trigraphs-1.c
new file mode 100644
index 00000000000..efd011ae733
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c11-trigraphs-1.c
@@ -0,0 +1,5 @@
+/* Test trigraphs supported in C11. */
+/* { dg-do run } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+#include "trigraphs.c"
diff --git a/gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-1.c b/gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-1.c
new file mode 100644
index 00000000000..bbc21522032
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-1.c
@@ -0,0 +1,10 @@
+/* Test trigraphs not supported in C2x. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+const char a[] = "??=??(??/??/??)??'??<??!??>??-";
+const char b[] = "?""?=?""?(?""?/?""?/?""?)?""?'?""?<?""?!?""?>?""?-";
+
+_Static_assert (sizeof a == sizeof b, "checking trigraph conversions");
+
+/* { dg-prune-output "\\\[-Wtrigraphs" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-2.c b/gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-2.c
new file mode 100644
index 00000000000..38ee489f777
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-2.c
@@ -0,0 +1,5 @@
+/* Test trigraphs supported in C2x with -trigraphs used. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -pedantic-errors -trigraphs" } */
+
+#include "trigraphs.c"
diff --git a/libcpp/init.cc b/libcpp/init.cc
index 41b10b3d114..3e5601a5d96 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -112,7 +112,7 @@ static const struct lang_flags lang_defaults[] =
/* STDC99 */ { 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
/* STDC11 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
/* STDC17 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
- /* STDC2X */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0 },
+ /* STDC2X */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0 },
/* GNUCXX */ { 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
/* CXX98 */ { 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 },
/* GNUCXX11 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-05 22:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 22:06 [committed] preprocessor: Disable trigraphs for C2x Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).