From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 069A8385773C for ; Tue, 18 Jul 2023 17:33:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 069A8385773C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689701609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QkajGyHVOCxxjblDb4vXKHUoUUQq5iCPDqBDg7TD7wI=; b=ZcPGzKCTKP0B2cE9SZcISMlEjOvZW2GFqJ566UT4xRCauFK7tviSOdR0QNUmSlz3yPqc3R y7v01Sqz697e4nIrv4LpOjs56wNS8OerJ3vAL92DgA+iLneVflCrsHdoVNWV8hpgvB/jda BKBQQY0LPTcVQJvAg0Ocr1qjyl2rF14= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-118-_JT7w176PRS49A8gfw18wA-1; Tue, 18 Jul 2023 13:33:26 -0400 X-MC-Unique: _JT7w176PRS49A8gfw18wA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 654C91C2C5A0 for ; Tue, 18 Jul 2023 17:33:26 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.10.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4673A492B01; Tue, 18 Jul 2023 17:33:26 +0000 (UTC) From: Marek Polacek To: GCC Patches Cc: Jason Merrill Subject: [pushed] c++: Add tests for P2621, no UB in lexer [PR110340] Date: Tue, 18 Jul 2023 13:33:14 -0400 Message-ID: <20230718173314.72666-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- C++26 P2621 removes UB in the lexer and either makes the construct valid or ill-formed. We're already handling this correctly so this patch only adds tests. PR c++/110340 gcc/testsuite/ChangeLog: * g++.dg/cpp/string-4.C: New test. * g++.dg/cpp/ucn-2.C: New test. --- gcc/testsuite/g++.dg/cpp/string-4.C | 6 ++++++ gcc/testsuite/g++.dg/cpp/ucn-2.C | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp/string-4.C create mode 100644 gcc/testsuite/g++.dg/cpp/ucn-2.C diff --git a/gcc/testsuite/g++.dg/cpp/string-4.C b/gcc/testsuite/g++.dg/cpp/string-4.C new file mode 100644 index 00000000000..37d0388413c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/string-4.C @@ -0,0 +1,6 @@ +// P2621R2 - UB? In My Lexer? +// { dg-do compile } + +// [lex.phases] If a U+0027 APOSTROPHE or a U+0022 QUOTATION +// MARK matches the last category, the program is ill-formed. +const char * foo=" // { dg-error "terminating|expected" } diff --git a/gcc/testsuite/g++.dg/cpp/ucn-2.C b/gcc/testsuite/g++.dg/cpp/ucn-2.C new file mode 100644 index 00000000000..c5583e06dd6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/ucn-2.C @@ -0,0 +1,15 @@ +// P2621R2 - UB? In My Lexer? +// { dg-do compile } + +// Line splicing can form a universal-character-name [lex.charset]. +int \\ +u\ +0\ +3\ +9\ +1 = 0; + +// [cpp.concat] Concatenation can form a universal-character-name. +#define CONCAT(x,y) x##y + +int CONCAT(\,u0393)=0; base-commit: 05fc7db93452841280ddc5cdf71b33498ed576dc -- 2.41.0