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.
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
--- /dev/null
+
+struct fpu {
+ struct NAME {
+ int state;
+ } NAME;
+};
--- /dev/null
+// { dg-additional-options -fmodule-header }
+// PR c++ 98530 stat-hack inside a structure
+// { dg-module-cmi {} }
+
+#include "stat-mem-1.h"
--- /dev/null
+// { dg-additional-options "-fmodules-ts -fno-module-lazy" }
+
+#include "stat-mem-1.h"
+import "stat-mem-1_a.H";