Bootstrapped and regtested on x86_64-pc-linux-gnu, does this
look OK for trunk/15?
-- >8 --
Since we don't implement deferred noexcept-spec parsing of a friend
declaration, the r15-2117 change to diagnose name lookup failure for
the current instantiation ahead of time needs to compensate by
suppressing the name lookup failure in this case.
PR c++/122668
PR c++/114764
gcc/cp/ChangeLog:
* pt.cc (dependentish_scope_p): Return true for the current
instantiation from within an immediately parsed noexcept-spec.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept91.C: New test.
---
gcc/cp/pt.cc | 10 +++++++++-
gcc/testsuite/g++.dg/cpp0x/noexcept91.C | 15 +++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept91.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index b7cb807d8daa..f132f8b39d24 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -29057,7 +29057,15 @@ dependent_scope_p (tree scope)
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 scope as dependent
+ in this case to avoid bogus name lookup failures (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
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept91.C
b/gcc/testsuite/g++.dg/cpp0x/noexcept91.C
new file mode 100644
index 000000000000..590dfa6162a3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept91.C
@@ -0,0 +1,15 @@
+// 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)), "");
+}
--
2.52.0.rc2.3.gfd372d9b1a