From patchwork Mon Sep 5 22:06:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1674446 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MM2fl1Z9xz1yh5 for ; Tue, 6 Sep 2022 08:06:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 494343851A87 for ; Mon, 5 Sep 2022 22:06:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 447383858D28 for ; Mon, 5 Sep 2022 22:06:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 447383858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,292,1654588800"; d="scan'208";a="82369542" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 05 Sep 2022 14:06:19 -0800 IronPort-SDR: DPU6Pru7+gAoUcoelSI2+db06cdGaZde1tzmWQY2cMcrAIGH10rL5KcYYM/Iw9tI+n8e4WZULw IBX+tGJTUjqMmtyt5rbEcFV8o8f3QyfdIVuzvbH2upT5AQ6krAfc99EThbBb+6Xt83YPZDfbcd SiI8gFdSdoF0BovkEtXIMtYxReLItvAI7esW+QYod1CWKwUFW3iNz6jMzi1Yh3cnR+32kG1KGa kzn0pA+sGxtTDGCmnMMf0DspfYvUvVLETkx5kXCCWJqB0qG/d/gMwJblNewlzpkNBbjjXUdF8x CIQ= Date: Mon, 5 Sep 2022 22:06:13 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Subject: [committed] preprocessor: Disable trigraphs for C2x Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3116.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SCC_5_SHORT_WORD_LINES, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "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 },