We were tsubsting trait arguments wrong: a type gets tsubst, not tsubst_copy.

Tested x86_64-pc-linux-gnu, applying to trunk, 4.7, 4.8.
commit bf602b5f571b47d41ee271fea8d7c6dfa11433ec
Author: Jason Merrill <ja...@redhat.com>
Date:   Mon Jan 27 13:29:01 2014 -0500

    	PR c++/58504
    	* pt.c (tsubst_copy_and_build) [TRAIT_EXPR]: Use tsubst for
    	types.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 661143a..47d07db 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14974,12 +14974,12 @@ tsubst_copy_and_build (tree t,
 
     case TRAIT_EXPR:
       {
-	tree type1 = tsubst_copy (TRAIT_EXPR_TYPE1 (t), args,
-				  complain, in_decl);
+	tree type1 = tsubst (TRAIT_EXPR_TYPE1 (t), args,
+			     complain, in_decl);
 
 	tree type2 = TRAIT_EXPR_TYPE2 (t);
 	if (type2)
-	  type2 = tsubst_copy (type2, args, complain, in_decl);
+	  type2 = tsubst (type2, args, complain, in_decl);
 	
 	RETURN (finish_trait_expr (TRAIT_EXPR_KIND (t), type1, type2));
       }
diff --git a/gcc/testsuite/g++.dg/ext/traits1.C b/gcc/testsuite/g++.dg/ext/traits1.C
new file mode 100644
index 0000000..24099e5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/traits1.C
@@ -0,0 +1,4 @@
+// PR c++/58504
+
+template<bool = __has_nothrow_assign(void)> struct A {};
+A<> a;

Reply via email to