From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 20DD6395182E; Mon, 16 Aug 2021 16:52:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20DD6395182E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-2933] libstdc++: Use qualified-id for class member constant [PR101937] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: db853ff78a34fef25bc16133e0367a64526f9f4e X-Git-Newrev: 6c25932ac399423b09b730fb8f894ada568deb2a Message-Id: <20210816165248.20DD6395182E@sourceware.org> Date: Mon, 16 Aug 2021 16:52:48 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Aug 2021 16:52:48 -0000 https://gcc.gnu.org/g:6c25932ac399423b09b730fb8f894ada568deb2a commit r12-2933-g6c25932ac399423b09b730fb8f894ada568deb2a Author: Jonathan Wakely Date: Mon Aug 16 15:35:58 2021 +0100 libstdc++: Use qualified-id for class member constant [PR101937] The expression ctx._M_indent is not a constant expression when ctx is a reference parameter, even though _M_indent is an enumerator. Rename it to _S_indent to be consistent with our conventions, and refer to it as PrintContext::_S_indent to be valid C++ code (at least until P2280 is accepted as a DR). Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: PR libstdc++/101937 * src/c++11/debug.cc (PrintContext::_M_indent): Replace with a static data member. (print_word): Use qualified-id to access it. Diff: --- libstdc++-v3/src/c++11/debug.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index 33d76bfcaab..0128535135e 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -573,8 +573,8 @@ namespace : _M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false) { get_max_length(_M_max_length); } + static constexpr int _S_indent = 4; std::size_t _M_max_length; - enum { _M_indent = 4 } ; std::size_t _M_column; bool _M_first_line; bool _M_wordwrap; @@ -603,7 +603,7 @@ namespace if (length == 0) return; - // Consider first '\n' at begining cause it impacts column. + // First consider '\n' at the beginning because it impacts the column. if (word[0] == '\n') { fprintf(stderr, "\n"); @@ -625,8 +625,8 @@ namespace // If this isn't the first line, indent if (ctx._M_column == 1 && !ctx._M_first_line) { - const char spacing[ctx._M_indent + 1] = " "; - print_raw(ctx, spacing, ctx._M_indent); + const char spacing[PrintContext::_S_indent + 1] = " "; + print_raw(ctx, spacing, PrintContext::_S_indent); } int written = fprintf(stderr, "%.*s", (int)length, word);