From patchwork Wed Sep 25 12:24:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1167178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509546-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tsE6VEcV"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46dch43RR2z9sBF for ; Wed, 25 Sep 2019 22:24:50 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=Suiet0QnmaqhYWNnLxt5iNJN/P7sS3L1Kr8GqxY1sqb6lR+m8TqNc bnsPvPhDYcBphFbndQYNecH6EPuXYln+gND2IHjhUIXoioXzPR9F+EgV7Dxo4HNV VjveUMXKyvo5oyScJfqvgHGYGLJdIShPugWaRJPaM+OVxLrf7A+zE8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=rIZKu5wY/vnEsMErmGmvHk6gAYY=; b=tsE6VEcVNyBAid8cPYGB eBfDhRW4y8NXcdvEalnXuF2L7U8hPUuIlZ3XqLEW8hknSJVnDdCUmQOTmPf/I8lY UFKlpPpTque1sQbbngaL6y3ILZC7HAnTJzbJvfTrhJADaqPaR4hVzpHZdKMXnrA2 RS6DUqzRuOUZ4B5dqSf5nTE= Received: (qmail 41017 invoked by alias); 25 Sep 2019 12:24:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 37125 invoked by uid 89); 25 Sep 2019 12:24:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Greylist:Wed X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Sep 2019 12:24:14 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B13A106DADB; Wed, 25 Sep 2019 12:24:11 +0000 (UTC) Received: from localhost (unknown [10.33.36.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 241DF601B7; Wed, 25 Sep 2019 12:24:10 +0000 (UTC) Date: Wed, 25 Sep 2019 13:24:09 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] Implement LWG 3296 for basic_regex::assign Message-ID: <20190925122409.GA7640@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.12.1 (2019-06-15) * include/bits/regex.h (basic_regex::assign(const C*, size_t, flag_type)): Add default argument (LWG 3296). * testsuite/28_regex/basic_regex/assign/char/lwg3296.cc: New test. * testsuite/28_regex/basic_regex/assign/wchar_t/lwg3296.cc: New test. Tested x86_64-linux, committed to trunk. commit b4ad7c7f6854ced87e46332da5ea49107cfc5318 Author: Jonathan Wakely Date: Wed Sep 25 13:01:04 2019 +0100 Implement LWG 3296 for basic_regex::assign * include/bits/regex.h (basic_regex::assign(const C*, size_t, flag_type)): Add default argument (LWG 3296). * testsuite/28_regex/basic_regex/assign/char/lwg3296.cc: New test. * testsuite/28_regex/basic_regex/assign/wchar_t/lwg3296.cc: New test. diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index b30b41a0759..7869c3fd1c1 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -628,8 +628,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * expression pattern interpreted according to @p __flags. If * regex_error is thrown, *this remains unchanged. */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3296. Inconsistent default argument for basic_regex<>::assign basic_regex& - assign(const _Ch_type* __p, std::size_t __len, flag_type __flags) + assign(const _Ch_type* __p, size_t __len, flag_type __flags = ECMAScript) { return this->assign(string_type(__p, __len), __flags); } /** diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/lwg3296.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/lwg3296.cc new file mode 100644 index 00000000000..29256bbbf03 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/lwg3296.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { target c++11 } } + +#include +#include + +void +test01() +{ + std::regex r("", std::regex_constants::grep); + r.assign("(.)[", 3); // LWG 3296 + VERIFY( r.flags() == std::regex_constants::ECMAScript ); + VERIFY( r.mark_count() == 1 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/assign/wchar_t/lwg3296.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/wchar_t/lwg3296.cc new file mode 100644 index 00000000000..302ebd6b4f9 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/wchar_t/lwg3296.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { target c++11 } } + +#include +#include + +void +test01() +{ + std::wregex r(L"", std::regex_constants::grep); + r.assign(L"(.)[", 3); // LWG 3296 + VERIFY( r.flags() == std::regex_constants::ECMAScript ); + VERIFY( r.mark_count() == 1 ); +} + +int +main() +{ + test01(); +}