When parsing a variadic type trait intrinsic, we build up the list of
trailing arguments in reverse, but we neglect to reverse the list to
the true order afterwards. This causes us to confuse the meaning of
e.g. __is_xible(x, y, z) vs __is_xible(x, z, y).
Note that this bug doesn't affect the library traits because they pass a
pack expansion as the single trailing argument to __is_xible, which gets
expanded in the correct order by tsubst_tree_list.
gcc/cp/ChangeLog:
* parser.c (cp_parser_trait_expr): Call nreverse on the reversed
list of trailing arguments.
gcc/testsuite/ChangeLog:
* g++.dg/ext/is_constructible6.C: New test.
return error_mark_node;
type2 = tree_cons (NULL_TREE, elt, type2);
}
+ type2 = nreverse (type2);
}
location_t finish_loc = cp_lexer_peek_token (parser->lexer)->location;
--- /dev/null
+// Verify we respect the order of trailing arguments passed to
+// __is_constructible.
+
+struct A { };
+struct B { };
+struct C { C(A, B); };
+
+extern int n[true];
+extern int n[ __is_constructible(C, A, B)];
+extern int n[!__is_constructible(C, B, A)];