This is the mail archive of the 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]

Re: [C++ PATCH] Fix up DECL_ARG_TYPE (PR c++/36631)

On Fri, Nov 07, 2008 at 04:13:53PM -0500, Jason Merrill wrote:
> Jakub Jelinek wrote:
>> I'm afraid requiring complete type in tsubst_decl for PARM_DECL's type might
>> be problematic, as that would mean instantiate_template_class in midst
>> of another instantiate_template_class.
> I'm pretty sure that already happens all the time.

--- gcc/cp/pt.c	2008-10-14 22:09:53.000000000 +0200
+++ gcc/cp/pt.c	2008-11-07 23:18:35.000000000 +0100
@@ -8355,7 +8355,10 @@ tsubst_decl (tree t, tree args, tsubst_f
             DECL_CONTEXT (r) = NULL_TREE;
             if (!DECL_TEMPLATE_PARM_P (r))
-              DECL_ARG_TYPE (r) = type_passed_as (type);
+	      {
+		complete_type (type);
+		DECL_ARG_TYPE (r) = type_passed_as (type);
+	      }
 	    apply_late_template_attributes (&r, DECL_ATTRIBUTES (r), 0,
 					    args, complain, in_decl);
might help in a few cases (e.g. on the testcase from the PR), but certainly
not all.  Say:

struct C
  C ();
  void foo (C, C);

void bar (void)
  C c; (c, c);

template <typename T> struct D
  D ();
  void foo (D, D);

void baz (void)
  D<int> d; (d, d);

When type_passed_as is called for C::foo, C is still not complete and
complete_type doesn't do anything on it, when the above complete_type added
to tsubst_decl is called on D, D is TYPE_BEING_DEFINED and thus
complete_type doesn't do anything either.  So on this testcase,
with or without the patch, the middle end gets incorrect DECL_ARG_TYPE
on the last 2 args of all foo methods.


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