bool
dependentish_scope_p (tree scope)
{
- return dependent_scope_p (scope) || any_dependent_bases_p (scope);
+ return dependent_scope_p (scope) || any_dependent_bases_p (scope)
+ /* A noexcept-spec is a complete-class context, so this should never hold.
+ But since we don't implement deferred noexcept-spec parsing of a friend
+ declaration (PR114764) we compensate by treating the current
+ instantiation as dependent to avoid bogus name lookup failures in this
+ case (PR122668). */
+ || (cp_noexcept_operand
+ && CLASS_TYPE_P (scope)
+ && TYPE_BEING_DEFINED (scope)
+ && dependent_type_p (scope));
}
/* T is a SCOPE_REF. Return whether it represents a non-static member of
--- /dev/null
+// PR c++/122668
+// { dg-do compile { target c++11 } }
+
+template<class T>
+struct A {
+ friend void f1(A& a) noexcept(noexcept(a.g(0))) { }
+ friend void f2(A& a) noexcept(noexcept(A::g(0))) { }
+ static void g(int) noexcept;
+};
+
+int main() {
+ A<int> a;
+ static_assert(noexcept(f1(a)), "");
+ static_assert(noexcept(f2(a)), "");
+}