+2017-10-23 Jason Merrill <jason@redhat.com>
+
+ PR c++/77369 - wrong noexcept handling in C++14 and below
+ * tree.c (strip_typedefs): Canonicalize TYPE_RAISES_EXCEPTIONS.
+
2017-10-20 Nathan Sidwell <nathan@acm.org>
* class.c (layout_class_type): Cleanup as-base creation, determine
is_variant = true;
type = strip_typedefs (TREE_TYPE (t), remove_attributes);
- changed = type != TREE_TYPE (t) || is_variant;
+ tree canon_spec = (flag_noexcept_type
+ ? canonical_eh_spec (TYPE_RAISES_EXCEPTIONS (t))
+ : NULL_TREE);
+ changed = (type != TREE_TYPE (t) || is_variant
+ || TYPE_RAISES_EXCEPTIONS (t) != canon_spec);
for (arg_node = TYPE_ARG_TYPES (t);
arg_node;
type_memfn_rqual (t));
}
- if (TYPE_RAISES_EXCEPTIONS (t))
- result = build_exception_variant (result,
- TYPE_RAISES_EXCEPTIONS (t));
+ if (canon_spec)
+ result = build_exception_variant (result, canon_spec);
if (TYPE_HAS_LATE_RETURN_TYPE (t))
TYPE_HAS_LATE_RETURN_TYPE (result) = 1;
}
--- /dev/null
+// PR c++/77369
+// { dg-do compile { target c++11 } }
+
+template<typename F> int caller(F f) noexcept(noexcept(f())) { f(); return 0; }
+
+void func1() noexcept { }
+
+void func2() { throw 1; }
+
+int instantiate_caller_with_func1 = caller(func1);
+
+static_assert( !noexcept(caller(func2)), "" );
void foo () throw () {} // { dg-bogus "mangled name" }
template <class T>
-T bar (T x) { return x; } // { dg-warning "mangled name" "" { target c++14_down } }
+T bar (T x) { return x; }
void baz () { // { dg-bogus "mangled name" }
return (bar (foo)) ();