From: Jonathan Wakely Date: Fri, 12 Oct 2018 11:37:46 +0000 (+0100) Subject: PR libstdc++/85098 add missing definitions for static constants X-Git-Tag: releases/gcc-6.5.0~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d75d90a3d8b2ed3952769ba4d37f8782ef5ff02;p=thirdparty%2Fgcc.git PR libstdc++/85098 add missing definitions for static constants In C++11 and C++14 any odr-use of these constants requires a definition at namespace-scope. In C++17 they are implicitly inline and so the namespace-scope redeclarations are redundant (and allowing them is deprecated). Backport from mainline 2018-05-18 Jonathan Wakely PR libstdc++/85098 * include/bits/regex.h [__cplusplus < 201703L] (basic_regex::icase) (basic_regex::nosubs, basic_regex::optimize, basic_regex::collate) (basic_regex::ECMAScript, basic_regex::basic, basic_regex::extended) (basic_regex::awk, basic_regex::grep, basic_regex::egrep): Add definitions. * include/bits/regex_automaton.h (_NFA::_M_insert_state): Adjust whitespace. * testsuite/28_regex/basic_regex/85098.cc: New From-SVN: r265083 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9328e36138e1..d29dfece6cc0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,18 @@ +2018-10-12 Jonathan Wakely + + Backport from mainline + 2018-05-18 Jonathan Wakely + + PR libstdc++/85098 + * include/bits/regex.h [__cplusplus < 201703L] (basic_regex::icase) + (basic_regex::nosubs, basic_regex::optimize, basic_regex::collate) + (basic_regex::ECMAScript, basic_regex::basic, basic_regex::extended) + (basic_regex::awk, basic_regex::grep, basic_regex::egrep): Add + definitions. + * include/bits/regex_automaton.h (_NFA::_M_insert_state): Adjust + whitespace. + * testsuite/28_regex/basic_regex/85098.cc: New + 2018-10-08 Joseph Myers Backport from mainline diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index cf7aa3ee4bff..262c76e45f16 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -785,6 +785,46 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _AutomatonPtr _M_automaton; }; + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::icase; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::nosubs; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::optimize; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::collate; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::ECMAScript; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::basic; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::extended; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::awk; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::grep; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::egrep; + /** @brief Standard regular expressions. */ typedef basic_regex regex; diff --git a/libstdc++-v3/include/bits/regex_automaton.h b/libstdc++-v3/include/bits/regex_automaton.h index 07158c4926b7..ab2de45324b6 100644 --- a/libstdc++-v3/include/bits/regex_automaton.h +++ b/libstdc++-v3/include/bits/regex_automaton.h @@ -332,7 +332,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "Number of NFA states exceeds limit. Please use shorter regex " "string, or use smaller brace expression, or make " "_GLIBCXX_REGEX_STATE_LIMIT larger."); - return this->size()-1; + return this->size() - 1; } // Eliminate dummy node in this NFA to make it compact. diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/85098.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/85098.cc new file mode 100644 index 000000000000..173b1901a7cd --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/basic_regex/85098.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2018 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-options "-O0" } +// { dg-do link { target c++11 } } + +#include + +void f(const std::regex_constants::syntax_option_type&) { } + +void +test01() +{ + f(std::regex::icase); + f(std::regex::nosubs); + f(std::regex::optimize); + f(std::regex::collate); + f(std::regex::ECMAScript); + f(std::regex::basic); + f(std::regex::extended); + f(std::regex::awk); + f(std::regex::grep); + f(std::regex::egrep); + // f(std::regex::multiline); +} + +int +main() +{ + test01(); +}