diff mbox

[C++] Fix pastos (?) in make_typename_type calls

Message ID 500EAFFC.8030703@oracle.com
State New
Headers show

Commit Message

Paolo Carlini July 24, 2012, 2:23 p.m. UTC
Hi,

while looking into the re-opened c++/51213 (doesn't seem trivial: 
details soon, I hope) I noticed things which look like old pastos: in 
convert_template_argument and tsubst we are computing complain & 
tf_error for the - tsubst_flags_t, not bool - fourth argument of 
make_typename_type. That doesn't make much sense to me and the below, 
as-is, passes testing.

Thanks,
Paolo.

///////////////////////////
2012-07-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* pt.c (convert_template_argument, tsubst): Fix pasto in the fourth
	argument to make_typename_type (complain & tf_error -> complain).

Comments

Jason Merrill July 24, 2012, 6:06 p.m. UTC | #1
On 07/24/2012 10:23 AM, Paolo Carlini wrote:
> while looking into the re-opened c++/51213 (doesn't seem trivial:
> details soon, I hope) I noticed things which look like old pastos: in
> convert_template_argument and tsubst we are computing complain &
> tf_error for the - tsubst_flags_t, not bool - fourth argument of
> make_typename_type. That doesn't make much sense to me and the below,
> as-is, passes testing.

The point of this use of (complain & tf_error) is to mask out flags we 
don't want and leave only tf_error.  It may or may not be needed, but 
it's not a pasto.

Jason
Paolo Carlini July 24, 2012, 7:05 p.m. UTC | #2
On 07/24/2012 08:06 PM, Jason Merrill wrote:
> On 07/24/2012 10:23 AM, Paolo Carlini wrote:
>> while looking into the re-opened c++/51213 (doesn't seem trivial:
>> details soon, I hope) I noticed things which look like old pastos: in
>> convert_template_argument and tsubst we are computing complain &
>> tf_error for the - tsubst_flags_t, not bool - fourth argument of
>> make_typename_type. That doesn't make much sense to me and the below,
>> as-is, passes testing.
>
> The point of this use of (complain & tf_error) is to mask out flags we 
> don't want and leave only tf_error.  It may or may not be needed, but 
> it's not a pasto.
Ok, thanks. Probably loooked to me like a pasto because we are using 
this kind of clearing in very few places, if at all (if I'm not mistaken).

Anyway, in the meanwhile I had a closer look and I think isn't really 
needed because:
1- make_typename_type and the functions it calls (like 
perform_or_defer_access_check) only pay attention to tf_error (only 
make_typename_type itself to tf_keep_type_decl).
2- make_typename_type checks indeed tf_keep_type_decl but calling it 
with complain & tf_error (as convert_template_argument does) vs plain 
complain cannot make a difference, because tf_keep_type_decl cannot be 
"randomly" set in complain, because in the whole front-end we set 
tf_keep_type_decl *only* in the flags we pass to make_typename_type 
itself from tsubst.

Thus, all in all, I propose doing the change anyway, of course with a 
different ChangeLog: if what I summarized above is correct the risk of 
breaking something is really tiny and the code would become a tad simpler.

Paolo.
Jason Merrill July 24, 2012, 7:28 p.m. UTC | #3
On 07/24/2012 03:05 PM, Paolo Carlini wrote:
> Thus, all in all, I propose doing the change anyway, of course with a
> different ChangeLog: if what I summarized above is correct the risk of
> breaking something is really tiny and the code would become a tad simpler.

OK.

Jason
diff mbox

Patch

Index: pt.c
===================================================================
--- pt.c	(revision 189808)
+++ pt.c	(working copy)
@@ -6139,7 +6139,7 @@  convert_template_argument (tree parm,
       orig_arg = make_typename_type (TREE_OPERAND (arg, 0),
 				     TREE_OPERAND (arg, 1),
 				     typename_type,
-				     complain & tf_error);
+				     complain);
       arg = orig_arg;
       is_type = 1;
     }
@@ -11402,7 +11402,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain
 	  }
 
 	f = make_typename_type (ctx, f, typename_type,
-				(complain & tf_error) | tf_keep_type_decl);
+				complain | tf_keep_type_decl);
 	if (f == error_mark_node)
 	  return f;
 	if (TREE_CODE (f) == TYPE_DECL)