bool maybe_incomplete = BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P (baselink);
baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1,
complain);
- if (maybe_incomplete)
- {
- /* Filter out from the new lookup set those functions which didn't
- appear in the original lookup set (in a less specialized form).
- This is needed to preserve the consistency of member lookup
- performed in an incomplete-class context, within which
- later-declared members ought to remain invisible. */
- BASELINK_FUNCTIONS (baselink)
- = filter_memfn_lookup (fns, BASELINK_FUNCTIONS (baselink),
- binfo_type);
- BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P (baselink) = true;
- }
-
if (!baselink)
{
if (complain & tf_error)
return error_mark_node;
}
+ if (maybe_incomplete)
+ {
+ /* Filter out from the new lookup set those functions which didn't
+ appear in the original lookup set (in a less specialized form).
+ This is needed to preserve the consistency of member lookup
+ performed in an incomplete-class context, within which
+ later-declared members ought to remain invisible. */
+ BASELINK_FUNCTIONS (baselink)
+ = filter_memfn_lookup (fns, BASELINK_FUNCTIONS (baselink),
+ binfo_type);
+ BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P (baselink) = true;
+ }
+
fns = BASELINK_FUNCTIONS (baselink);
}
else
--- /dev/null
+// PR c++/120876
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct S {
+ static bool foo (decltype (bar (T {}))); // { dg-error "'bar' was not declared in this scope; did you mean 'baz'\\\?" }
+ static constexpr bool s = foo (0); // { dg-error "declaration of 'S<int>::foo' depends on itself" }
+};
+
+void
+baz ()
+{
+ S <int>::s;
+}