From: Nathan Sidwell <nathan@acm.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: c++: Stat-hack for members [PR 98530]
Date: Thu, 21 Jan 2021 07:54:02 -0500 [thread overview]
Message-ID: <6d2023c8-6314-b788-26b5-26e05ffd7437@acm.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]
This was a header file that deployed the stat-hack inside a class
(both a member-class and a [non-static data] member had the same
name). Due to the way that's represented in name lookup we missed the
class. Sadly just changing the representation globally has
detrimental effects elsewhere, and this is a rare case, so just
creating a new overload on the fly shouldn't be a problem.
PR c++/98530
gcc/cp/
* name-lookup.c (lookup_class_binding): Rearrange a stat-hack.
gcc/testsuite/
* g++.dg/modules/stat-mem-1.h: New.
* g++.dg/modules/stat-mem-1_a.H: New.
* g++.dg/modules/stat-mem-1_b.C: New.
--
Nathan Sidwell
[-- Attachment #2: pr98530.diff --]
[-- Type: text/x-patch, Size: 1823 bytes --]
diff --git c/gcc/cp/name-lookup.c w/gcc/cp/name-lookup.c
index b4b6c0b81b5..c99f2e3622d 100644
--- c/gcc/cp/name-lookup.c
+++ w/gcc/cp/name-lookup.c
@@ -3926,11 +3926,16 @@ lookup_class_binding (tree klass, tree name)
vec<tree, va_gc> *member_vec = CLASSTYPE_MEMBER_VEC (klass);
found = member_vec_binary_search (member_vec, name);
- if (IDENTIFIER_CONV_OP_P (name))
+ if (!found)
+ ;
+ else if (STAT_HACK_P (found))
+ /* Rearrange the stat hack so that we don't need to expose that
+ internal detail. */
+ found = ovl_make (STAT_TYPE (found), STAT_DECL (found));
+ else if (IDENTIFIER_CONV_OP_P (name))
{
gcc_checking_assert (name == conv_op_identifier);
- if (found)
- found = OVL_CHAIN (found);
+ found = OVL_CHAIN (found);
}
}
else
diff --git c/gcc/testsuite/g++.dg/modules/stat-mem-1.h w/gcc/testsuite/g++.dg/modules/stat-mem-1.h
new file mode 100644
index 00000000000..b5703ea2262
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/stat-mem-1.h
@@ -0,0 +1,6 @@
+
+struct fpu {
+ struct NAME {
+ int state;
+ } NAME;
+};
diff --git c/gcc/testsuite/g++.dg/modules/stat-mem-1_a.H w/gcc/testsuite/g++.dg/modules/stat-mem-1_a.H
new file mode 100644
index 00000000000..6daa137be4f
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/stat-mem-1_a.H
@@ -0,0 +1,5 @@
+// { dg-additional-options -fmodule-header }
+// PR c++ 98530 stat-hack inside a structure
+// { dg-module-cmi {} }
+
+#include "stat-mem-1.h"
diff --git c/gcc/testsuite/g++.dg/modules/stat-mem-1_b.C w/gcc/testsuite/g++.dg/modules/stat-mem-1_b.C
new file mode 100644
index 00000000000..9b83d4e6e30
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/stat-mem-1_b.C
@@ -0,0 +1,4 @@
+// { dg-additional-options "-fmodules-ts -fno-module-lazy" }
+
+#include "stat-mem-1.h"
+import "stat-mem-1_a.H";
reply other threads:[~2021-01-21 12:54 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=6d2023c8-6314-b788-26b5-26e05ffd7437@acm.org \
--to=nathan@acm.org \
--cc=gcc-patches@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).