public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Use qualified-id for class member constant [PR101937]
Date: Mon, 16 Aug 2021 17:53:45 +0100	[thread overview]
Message-ID: <YRqYGTkbFGRCDF8O@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

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 <jwakely@redhat.com>

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.

Tested x86_64-linux. Committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2028 bytes --]

commit 6c25932ac399423b09b730fb8f894ada568deb2a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Aug 16 15:35:58 2021

    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 <jwakely@redhat.com>
    
    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 --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);

                 reply	other threads:[~2021-08-16 16:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YRqYGTkbFGRCDF8O@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).