@@ -1217,6 +1217,10 @@ build_noexcept_spec (tree expr, int complain)
{
gcc_assert (processing_template_decl
|| TREE_CODE (expr) == DEFERRED_NOEXCEPT);
+ if (TREE_CODE (expr) != DEFERRED_NOEXCEPT)
+ /* Avoid problems with a function type built with a dependent typedef
+ being reused in another scope (c++/84045). */
+ expr = strip_typedefs_expr (expr);
return build_tree_list (expr, NULL_TREE);
}
}
new file mode 100644
@@ -0,0 +1,14 @@
+// PR c++/84045
+// { dg-do compile { target c++11 } }
+
+template <typename T> struct K {
+ static const bool d = true;
+};
+template <typename T, typename> struct B {
+ typedef K<T> D;
+ void foo () noexcept (D::d);
+};
+template <typename T> struct P {
+ P () noexcept (K<T>::d);
+};
+P<int> p;