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++: Fix testsuite no_pch directive
Date: Thu, 17 Aug 2023 08:45:05 +0100	[thread overview]
Message-ID: <20230817074625.868621-1-jwakely@redhat.com> (raw)

A new test I added was failing with -std=gnu++23 because that flag was
removed from the test options (but only after checking if it met the
c++20 effective target).

Tested x86_64-linux. Pushed to trunk.

-- >8 --

The { dg-add-options no_pch } directive is supposed to add a macro
definition that invalidates the PCH file, and ensures that the #include
directives in the test file are processed as written. But the proc that
adds the options actually removes all existing options, cancelling out
any previous dg-options directive.

This means that using no_pch will cause FAILs in a file that relies on
other options set by an earlier dg-options.

The no_pch directive was added for PR libstdc++/21769 where Janis
suggested adding it as return "$flags -D__GLIBCXX__=99999999" but what
was actually committed didn't include the $flags so replaced them.

Additionally, using no_pch  only prevents the precompiled version of
<bits/stdc++.h> from being included, it doesn't prevent the
non-precompiled version being included by -include bits/stdc++.h in the
test flags. Use regsub to filter that out of the options as well.

libstdc++-v3/ChangeLog:

	* testsuite/lib/dg-options.exp (add_options_for_no_pch): Remove
	any "-include bits/stdc++.h" from options and add the macro to
	the existing options instead of replacing them.
---
 libstdc++-v3/testsuite/lib/dg-options.exp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 73c1552e682..15e34f8a646 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -269,8 +269,10 @@ proc dg-require-target-fs-lwt { args } {
 }
 
 proc add_options_for_no_pch { flags } {
+    # Remove any inclusion of bits/stdc++.h from the options.
+    regsub -all -- "-include bits/stdc...h" $flags "" flags
     # This forces any generated and possibly included PCH to be invalid.
-    return "-D__GLIBCXX__=99999999"
+    return "$flags -D__GLIBCXX__=99999999"
 }
 
 # Add to FLAGS all the target-specific flags needed for networking.
-- 
2.41.0


                 reply	other threads:[~2023-08-17  7:46 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=20230817074625.868621-1-jwakely@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).