2011-04-07 Jason Merrill <jason@redhat.com>
+ PR c++/48468
+ * except.c (build_noexcept_spec): Propagate error_mark_node.
+ (finish_noexcept_expr): Likewise.
+
PR c++/48452
* typeck.c (build_x_compound_expr_from_list): Return error_mark_node
in SFINAE context.
{
tree fn;
+ if (expr == error_mark_node)
+ return error_mark_node;
+
if (processing_template_decl)
return build_min (NOEXCEPT_EXPR, boolean_type_node, expr);
return noexcept_true_spec;
else if (expr == boolean_false_node)
return noexcept_false_spec;
+ else if (expr == error_mark_node)
+ return error_mark_node;
else
{
gcc_assert (processing_template_decl || expr == error_mark_node);
2011-04-07 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/sfinae11.C: New.
+ * g++.dg/cpp0x/noexcept02.C: Fix.
+
* g++.dg/cpp0x/sfinae10.C: New.
* g++.dg/cpp0x/sfinae9.C: New.
template <class T1, class T2>
void f (T1, T2) noexcept(noexcept(T1(), T2()));
-SA(noexcept(f3(1,1)));
+struct B { };
+
+SA(noexcept(f3(1,B())));
SA(!noexcept(f3(1,A())));
SA(!noexcept(f3(A(),1)));
SA(!noexcept(f3(A(),A())));
--- /dev/null
+// PR c++/48468
+// { dg-options -std=c++0x }
+// { dg-prune-output "note" }
+
+template<class T>
+T&& declval() noexcept;
+
+template< class T >
+inline void f1( T& x ) noexcept( noexcept( declval<T&>().foo() ) )
+{
+ x.foo();
+}
+
+template< class T,
+ bool Noexcept = noexcept( declval<T&>().foo() )
+>
+inline void f2( T& x ) noexcept( Noexcept )
+{
+ x.foo();
+}
+
+// a common and trivial mistake
+template< class T >
+inline void f3( T& x ) noexcept( declval<T&>().foo() )
+{
+ x.foo();
+}
+
+struct X
+{
+ void foo();
+};
+
+struct Y
+{
+ void foo() noexcept;
+};
+
+struct Z {};
+
+int main()
+{
+ X x; Y y; Z z;
+
+ static_assert( !noexcept( f1(x) ), "OK." );
+ static_assert( !noexcept( f2(x) ), "OK." );
+ // static_assert( !noexcept( f3(x) ), "shall be ill-formed(OK)." );
+
+ static_assert( noexcept( f1(y) ), "OK." );
+ static_assert( noexcept( f2(y) ), "OK." );
+ // static_assert( noexcept( f3(y) ), "shall be ill-formed(OK)." );
+
+ static_assert( noexcept( f1(z) ), "shall be ill-formed." ); // { dg-error "no match" }
+ static_assert( noexcept( f2(z) ), "shall be ill-formed." ); // { dg-error "no match" }
+ static_assert( !noexcept( f3(z) ), "shall be ill-formed." ); // { dg-error "no match" }
+}