public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-2969] c++: implicit lookup of std::initializer_list [PR102576]
Date: Thu, 29 Sep 2022 20:27:49 +0000 (GMT)	[thread overview]
Message-ID: <20220929202749.6B92F3858C55@sourceware.org> (raw)

https://gcc.gnu.org/g:c2ee70f20de8133a88553270073226b0f3f55f62

commit r13-2969-gc2ee70f20de8133a88553270073226b0f3f55f62
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Sep 29 16:27:30 2022 -0400

    c++: implicit lookup of std::initializer_list [PR102576]
    
    Here the lookup for the implicit use of std::initializer_list fails
    because we do it using get_namespace_binding, which isn't import aware.
    Fix this by using lookup_qualified_name instead.
    
            PR c++/102576
    
    gcc/cp/ChangeLog:
    
            * pt.cc (listify): Use lookup_qualified_name instead of
            get_namespace_binding.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/modules/pr102576_a.H: New test.
            * g++.dg/modules/pr102576_b.C: New test.

Diff:
---
 gcc/cp/pt.cc                              | 5 +++--
 gcc/testsuite/g++.dg/modules/pr102576_a.H | 5 +++++
 gcc/testsuite/g++.dg/modules/pr102576_b.C | 9 +++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 0f92374f19a..258f76d6e47 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -29161,9 +29161,10 @@ finish_concept_definition (cp_expr id, tree init)
 static tree
 listify (tree arg)
 {
-  tree std_init_list = get_namespace_binding (std_node, init_list_identifier);
+  tree std_init_list = lookup_qualified_name (std_node, init_list_identifier);
 
-  if (!std_init_list || !DECL_CLASS_TEMPLATE_P (std_init_list))
+  if (std_init_list == error_mark_node
+      || !DECL_CLASS_TEMPLATE_P (std_init_list))
     {
       gcc_rich_location richloc (input_location);
       maybe_add_include_fixit (&richloc, "<initializer_list>", false);
diff --git a/gcc/testsuite/g++.dg/modules/pr102576_a.H b/gcc/testsuite/g++.dg/modules/pr102576_a.H
new file mode 100644
index 00000000000..87ba9b52031
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr102576_a.H
@@ -0,0 +1,5 @@
+// PR c++/102576
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+
+#include <initializer_list>
diff --git a/gcc/testsuite/g++.dg/modules/pr102576_b.C b/gcc/testsuite/g++.dg/modules/pr102576_b.C
new file mode 100644
index 00000000000..10251ed5304
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr102576_b.C
@@ -0,0 +1,9 @@
+// PR c++/102576
+// { dg-additional-options -fmodules-ts }
+
+import "pr102576_a.H";
+
+int main() {
+  for (int i : {1, 2, 3})
+    ;
+}

                 reply	other threads:[~2022-09-29 20:27 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=20220929202749.6B92F3858C55@sourceware.org \
    --to=ppalka@gcc.gnu.org \
    --cc=gcc-cvs@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).