This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/42364 (testsuite failures with -g)


function_parameter_expanded_from_pack_p was requiring parameters to have a name, which of course they don't need to have; this dated back to before the use of DECL_PARM_INDEX to identify parameters.

We were failing to set up variant types properly for typedefs when the type used attributes; applying the attributes stripped the typedef variant. So now we wait until after attributes to generate the typedef variant.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit c2c9e7f423e05a9a9c8b9fa8c709862bd249c99d
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Dec 14 16:08:34 2009 -0500

    	PR c++/42364
    	* pt.c (function_parameter_expanded_from_pack_p): Don't require
    	a pack to have a name.
    	(tsubst_decl): Do typedef magic after applying attributes.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6f76d46..9f03112 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2703,15 +2703,13 @@ get_function_template_decl (const_tree primary_func_tmpl_inst)
 bool
 function_parameter_expanded_from_pack_p (tree param_decl, tree pack)
 {
-    if (DECL_ARTIFICIAL (param_decl)
-	|| !function_parameter_pack_p (pack))
-      return false;
-
-    gcc_assert (DECL_NAME (param_decl) && DECL_NAME (pack));
+  if (DECL_ARTIFICIAL (param_decl)
+      || !function_parameter_pack_p (pack))
+    return false;
 
-    /* The parameter pack and its pack arguments have the same
-       DECL_PARM_INDEX.  */
-    return DECL_PARM_INDEX (pack) == DECL_PARM_INDEX (param_decl);
+  /* The parameter pack and its pack arguments have the same
+     DECL_PARM_INDEX.  */
+  return DECL_PARM_INDEX (pack) == DECL_PARM_INDEX (param_decl);
 }
 
 /* Determine whether ARGS describes a variadic template args list,
@@ -9246,7 +9244,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 	/* Create a new node for the specialization we need.  */
 	r = copy_decl (t);
 	if (type == NULL_TREE)
-	  type = tsubst (TREE_TYPE (t), args, complain, in_decl);
+	  {
+	    if (is_typedef_decl (t))
+	      type = DECL_ORIGINAL_TYPE (t);
+	    else
+	      type = TREE_TYPE (t);
+	    type = tsubst (type, args, complain, in_decl);
+	  }
 	if (TREE_CODE (r) == VAR_DECL)
 	  {
 	    /* Even if the original location is out of scope, the
@@ -9317,16 +9321,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 	      }
 	    determine_visibility (r);
 	  }
-	/* Preserve a typedef that names a type.  */
-	else if (TREE_CODE (r) == TYPE_DECL
-		 && DECL_ORIGINAL_TYPE (t)
-		 && type != error_mark_node)
-	  {
-	    DECL_ORIGINAL_TYPE (r) = tsubst (DECL_ORIGINAL_TYPE (t),
-					     args, complain, in_decl);
-	    TREE_TYPE (r) = type = build_variant_type_copy (type);
-	    TYPE_NAME (type) = r;
-	  }
 
 	if (!local_p)
 	  {
@@ -9364,6 +9358,14 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 	apply_late_template_attributes (&r, DECL_ATTRIBUTES (r),
 					(int) ATTR_FLAG_TYPE_IN_PLACE,
 					args, complain, in_decl);
+
+	/* Preserve a typedef that names a type.  */
+	if (is_typedef_decl (r))
+	  {
+	    DECL_ORIGINAL_TYPE (r) = NULL_TREE;
+	    set_underlying_type (r);
+	  }
+
 	layout_decl (r, 0);
       }
       break;
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic31.C b/gcc/testsuite/g++.dg/cpp0x/variadic31.C
index eacf568..db8daa8 100644
--- a/gcc/testsuite/g++.dg/cpp0x/variadic31.C
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic31.C
@@ -1,4 +1,4 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-options "-std=gnu++0x -g" }
 template<typename... T>
 void eat(T...) { }
 
diff --git a/gcc/testsuite/g++.dg/ext/attrib33.C b/gcc/testsuite/g++.dg/ext/attrib33.C
index 5b98984..55bfc4c 100644
--- a/gcc/testsuite/g++.dg/ext/attrib33.C
+++ b/gcc/testsuite/g++.dg/ext/attrib33.C
@@ -1,5 +1,6 @@
 // PR c++/35546
 // { dg-do compile }
+// { dg-options "-g" }
 
 template <int N>
 struct T

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]