On Thu, May 17, 2012 at 8:36 PM, Diego Novillo <[email protected]> wrote:
> On 12-05-17 10:52 , Michael Matz wrote:
>
>> Cross the bridge when you reach it, not before. Not everybody agrees that
>> the splitting of tree would be a good idea. Right now templates aren't
>> necessary, so you shouldn't use them. (well, and an investigation why
>> they come up with smaller .text would be in order anyway).
>
>
> I've been playing around with this patch a little bit. The main motivation
> for using templates here is to preserve the existing semantics. Note that
> the return type from the function mimics the type of the argument passed in.
> So, if the user passes a const_tree, the function returns a const_tree.
>
> The way to do this in C++ is to: (a) use templates (as in Lawrence's patch),
> or (b) produce overloaded variants for tree and const_tree.
>
> For trunk, we have a third option: (c) make these functions out-of-line
> functions that take const_tree and return tree. This slightly weakens the
> semantics of the checks, but it does not rely on C++ features.
>
> Options (a) or (b) are the same to me. Option (b) has the slight advantage
> that the code can be taken out of tree.h and buried in tree.c.
>
> The attached patch implements option (c). Should we consider this for trunk
> now and then just replace the CONST_CAST_TREE into C++ overloads?
As you retain the macros anyway you can simply not return anything
from the C++ checking functions define to a stmt expression
({ check_in_cxx (t); t; })
Btw, what breaks if the check functions always return a const_tree and
take a const_tree?
Richard.
>
> Thanks. Diego.
>
>
> 2012-05-17 Lawrence Crowl <[email protected]>
>
> * tree.h (tree_check): Declare.
> (TREE_CHECK): Use function above instead of __extension__.
> (tree_not_check): Declare.
> (TREE_NOT_CHECK): Use function above instead of __extension__.
> (tree_check2): Declare.
> (TREE_CHECK2): Use function above instead of __extension__.
> (tree_not_check2): Declare.
> (TREE_NOT_CHECK2): Use function above instead of __extension__.
> (tree_check3): Declare.
> (TREE_CHECK3): Use function above instead of __extension__.
> (tree_not_check3): Declare.
> (TREE_NOT_CHECK3): Use function above instead of __extension__.
> (tree_check4): Declare.
> (TREE_CHECK4): Use function above instead of __extension__.
> (tree_not_check4): Declare.
> (TREE_NOT_CHECK4): Use function above instead of __extension__.
> (tree_check5): Declare.
> (TREE_CHECK5): Use function above instead of __extension__.
> (tree_not_check5): Declare.
> (TREE_NOT_CHECK5): Use function above instead of __extension__.
> (contains_struct_check): Declare.
> (CONTAINS_STRUCT_CHECK): Use function above instead of
> __extension__.
> (tree_class_check): Declare.
> (TREE_CLASS_CHECK): Use function above instead of __extension__.
> (tree_range_check): Declare.
> (TREE_RANGE_CHECK): Use function above instead of __extension__.
> (omp_clause_subcode_check): Declare.
> (OMP_CLAUSE_SUBCODE_CHECK): Use function above instead of
> __extension__.
> (omp_clause_range_check): Declare.
> (OMP_CLAUSE_RANGE_CHECK): Use function above instead of
> __extension__.
> (expr_check): Declare.
> (EXPR_CHECK): Use function above instead of __extension__.
> (non_type_check): Declare.
> (NON_TYPE_CHECK): Use function above instead of __extension__.
> (tree_vec_elt_check): Declare.
> (TREE_VEC_ELT_CHECK): Use function above instead of
> __extension__.
> (omp_clause_elt_check): Declare.
> (OMP_CLAUSE_ELT_CHECK): Use function above instead of
> __extension__.
> (tree_operand_check): Declare.
> (TREE_OPERAND_CHECK): Use function above instead of
> __extension__.
> (tree_operand_check_code): Declare.
> (TREE_OPERAND_CHECK_CODE): Use function above instead of
>
> __extension__.
> (TREE_CHAIN): Simplify implementation.
> (TREE_TYPE): Simplify implementation.
> (tree_operand_length): Move for compilation dependences.
> * tree.c (tree_check): New.
> (tree_not_check): New.
> (tree_check2): New.
> (tree_not_check2): New.
> (tree_check3): New.
> (tree_not_check3): New.
> (tree_check4): New.
> (tree_not_check4): New.
> (tree_check5): New.
> (tree_not_check5): New.
> (contains_struct_check): New.
> (tree_range_check): New.
> (omp_clause_subcode_check): New.
> (omp_clause_range_check): New.
> (expr_check): New.
> (non_type_check): New.
> (tree_vec_elt_check): New.
> (omp_clause_elt_check): New.
> (tree_operand_check): New.
> (tree_operand_check_code): New.
>
> * gdbinit.in: (macro define __FILE__): New.
> (macro define __LINE__): New.
> (skip "tree.h"): New.