From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1105) id AC8173858D28; Mon, 5 Sep 2022 22:05:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC8173858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662415553; bh=um4YbyOKRtbaWDyrLoFJ50IKbK8UAkl3nlKgvzOzbN4=; h=From:To:Subject:Date:From; b=FvUv8TpCddfE2wWDAXA6/ouPnZ3T/QvxfKDRaV/x2jk0fRgcSO2XyIlH7BMKoUt3m EQRQgkFPYXcg8wNEoKBjCHduaukQ0ffEYdwglQzgg2a3uhFu23UEJCffKw5O9sQnW4 mXuHnAzRUaEsbLHj/gTVh0x5mmkC18ijNfT3IUp8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Joseph Myers To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2451] preprocessor: Disable trigraphs for C2x X-Act-Checkin: gcc X-Git-Author: Joseph Myers X-Git-Refname: refs/heads/master X-Git-Oldrev: 5f895f22173d78c1995a001d721d2ae1d075797b X-Git-Newrev: 5f38bf14bcb3ffe9fcd482b87cbf381df24a31df Message-Id: <20220905220553.AC8173858D28@sourceware.org> Date: Mon, 5 Sep 2022 22:05:53 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5f38bf14bcb3ffe9fcd482b87cbf381df24a31df commit r13-2451-g5f38bf14bcb3ffe9fcd482b87cbf381df24a31df Author: Joseph Myers Date: Mon Sep 5 22:05:06 2022 +0000 preprocessor: Disable trigraphs for C2x 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: --- gcc/testsuite/gcc.dg/cpp/c11-trigraphs-1.c | 5 +++++ gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-1.c | 10 ++++++++++ gcc/testsuite/gcc.dg/cpp/c2x-trigraphs-2.c | 5 +++++ libcpp/init.cc | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) 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 },