Re: [patch ada]: Fix boolean_type_node setup and some cleanup for boolean use
Ok, thanks for explaining it. So would be patch ok for apply without the precision setting? Sure, everything but the gcc-interface/misc.c part is OK. Thanks. -- Eric Botcazou
Re: [patch ada]: Fix boolean_type_node setup and some cleanup for boolean use
2011/5/18 Eric Botcazou ebotca...@adacore.com: Ok, thanks for explaining it. So would be patch ok for apply without the precision setting? Sure, everything but the gcc-interface/misc.c part is OK. Thanks. -- Eric Botcazou Hmm, you mean the initialization of boolean_false_node is wrong, too? Not sure here. As this patch introduces its use in the other parts. The precision part of course is wrong. Regards, Kai
Re: [patch ada]: Fix boolean_type_node setup and some cleanup for boolean use
2011-05-16 Kai Tietz PR middle-end/48989 * gcc-interface/trans.c (Exception_Handler_to_gnu_sjlj): Use boolean_false_node instead of integer_zero_node. (convert_with_check): Likewise. * gcc-interface/decl.c (choices_to_gnu): Likewise. OK for this part. * gcc-interface/misc.c (gnat_init): Set precision for generated boolean_type_node and initialize boolean_false_node. Not OK, you cannot set the precision of boolean_type_node to 1 in Ada. -- Eric Botcazou
Re: [patch ada]: Fix boolean_type_node setup and some cleanup for boolean use
2011/5/17 Eric Botcazou ebotca...@adacore.com: 2011-05-16 Kai Tietz PR middle-end/48989 * gcc-interface/trans.c (Exception_Handler_to_gnu_sjlj): Use boolean_false_node instead of integer_zero_node. (convert_with_check): Likewise. * gcc-interface/decl.c (choices_to_gnu): Likewise. OK for this part. * gcc-interface/misc.c (gnat_init): Set precision for generated boolean_type_node and initialize boolean_false_node. Not OK, you cannot set the precision of boolean_type_node to 1 in Ada. -- Eric Botcazou Hmm, sad. As the a check in tree-cfg for truth-expressions about having type-precision of 1 would be a good way. What is actual the cause for not setting type-precision here? At least in testcases I didn't found a regression caused by this. Regards, Kai
Re: [patch ada]: Fix boolean_type_node setup and some cleanup for boolean use
Hmm, sad. As the a check in tree-cfg for truth-expressions about having type-precision of 1 would be a good way. What is actual the cause for not setting type-precision here? But we are setting it: /* In Ada, we use an unsigned 8-bit type for the default boolean type. */ boolean_type_node = make_unsigned_type (8); TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE); See make_unsigned_type: /* Create and return a type for unsigned integers of PRECISION bits. */ tree make_unsigned_type (int precision) { tree type = make_node (INTEGER_TYPE); TYPE_PRECISION (type) = precision; fixup_unsigned_type (type); return type; } The other languages are changing the precision, but in Ada we need a standard scalar (precision == mode size) in order to support invalid values. At least in testcases I didn't found a regression caused by this. Right, I've just installed the attached testcase, it passes with the unmodified compiler but fails with your gcc-interface/misc.c change. 2011-05-17 Eric Botcazou ebotca...@adacore.com * gnat.dg/invalid1.adb: New test. -- Eric Botcazou -- { dg-do run } -- { dg-options -gnatws -gnatVa } pragma Initialize_Scalars; procedure Invalid1 is X : Boolean; A : Boolean := False; procedure Uninit (B : out Boolean) is begin if A then B := True; raise Program_Error; end if; end; begin -- first, check that initialize_scalars is enabled begin if X then A := False; end if; raise Program_Error; exception when Constraint_Error = null; end; -- second, check if copyback of an invalid value raises constraint error begin Uninit (A); if A then -- we expect constraint error in the 'if' above according to gnat ug: -- -- call. Note that there is no specific option to test `out' -- parameters, but any reference within the subprogram will be tested -- in the usual manner, and if an invalid value is copied back, any -- reference to it will be subject to validity checking. -- ... raise Program_Error; end if; raise Program_Error; exception when Constraint_Error = null; end; end;
Re: [patch ada]: Fix boolean_type_node setup and some cleanup for boolean use
2011/5/17 Eric Botcazou ebotca...@adacore.com: Hmm, sad. As the a check in tree-cfg for truth-expressions about having type-precision of 1 would be a good way. What is actual the cause for not setting type-precision here? But we are setting it: /* In Ada, we use an unsigned 8-bit type for the default boolean type. */ boolean_type_node = make_unsigned_type (8); TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE); See make_unsigned_type: /* Create and return a type for unsigned integers of PRECISION bits. */ tree make_unsigned_type (int precision) { tree type = make_node (INTEGER_TYPE); TYPE_PRECISION (type) = precision; fixup_unsigned_type (type); return type; } The other languages are changing the precision, but in Ada we need a standard scalar (precision == mode size) in order to support invalid values. At least in testcases I didn't found a regression caused by this. Right, I've just installed the attached testcase, it passes with the unmodified compiler but fails with your gcc-interface/misc.c change. 2011-05-17 Eric Botcazou ebotca...@adacore.com * gnat.dg/invalid1.adb: New test. -- Eric Botcazou Ok, thanks for explaining it. So would be patch ok for apply without the precision setting? Regards, Kai
[patch ada]: Fix boolean_type_node setup and some cleanup for boolean use
Hello, this fixes the ADA parts of PR middle-end/48989. For Fortran I am still looking, what actual the cause is. ChangeLog 2011-05-16 Kai Tietz PR middle-end/48989 * gcc-interface/trans.c (Exception_Handler_to_gnu_sjlj): Use boolean_false_node instead of integer_zero_node. (convert_with_check): Likewise. * gcc-interface/decl.c (choices_to_gnu): Likewise. * gcc-interface/misc.c (gnat_init): Set precision for generated boolean_type_node and initialize boolean_false_node. Patch bootstrapped on x86_64-pc-linux-gnu. And ran testsuite for ada. Ok for apply? Regards, Kai -- | (\_/) This is Bunny. Copy and paste | (='.'=) Bunny into your signature to help | ()_() him gain world domination Index: gcc/gcc/ada/gcc-interface/trans.c === --- gcc.orig/gcc/ada/gcc-interface/trans.c 2011-05-15 22:39:17.506308700 +0200 +++ gcc/gcc/ada/gcc-interface/trans.c 2011-05-15 23:28:32.502581600 +0200 @@ -3563,7 +3563,7 @@ Exception_Handler_to_gnu_sjlj (Node_Id g an if statement to select the proper exceptions. For Others, exclude exceptions where Handled_By_Others is nonzero unless the All_Others flag is set. For Non-ada, accept an exception if Lang is 'V'. */ - tree gnu_choice = integer_zero_node; + tree gnu_choice = boolean_false_node; tree gnu_body = build_stmt_group (Statements (gnat_node), false); Node_Id gnat_temp; @@ -3575,7 +3575,7 @@ Exception_Handler_to_gnu_sjlj (Node_Id g if (Nkind (gnat_temp) == N_Others_Choice) { if (All_Others (gnat_temp)) - this_choice = integer_one_node; + this_choice = boolean_true_node; else this_choice = build_binary_op @@ -7101,7 +7101,7 @@ convert_with_check (Entity_Id gnat_type, { /* Ensure GNU_EXPR only gets evaluated once. */ tree gnu_input = gnat_protect_expr (gnu_result); - tree gnu_cond = integer_zero_node; + tree gnu_cond = boolean_false_node; tree gnu_in_lb = TYPE_MIN_VALUE (gnu_in_basetype); tree gnu_in_ub = TYPE_MAX_VALUE (gnu_in_basetype); tree gnu_out_lb = TYPE_MIN_VALUE (gnu_base_type); Index: gcc/gcc/ada/gcc-interface/decl.c === --- gcc.orig/gcc/ada/gcc-interface/decl.c 2011-05-09 10:05:49.0 +0200 +++ gcc/gcc/ada/gcc-interface/decl.c2011-05-15 23:23:19.470831600 +0200 @@ -6595,7 +6595,7 @@ choices_to_gnu (tree operand, Node_Id ch { Node_Id choice; Node_Id gnat_temp; - tree result = integer_zero_node; + tree result = boolean_false_node; tree this_test, low = 0, high = 0, single = 0; for (choice = First (choices); Present (choice); choice = Next (choice)) @@ -6660,7 +6660,7 @@ choices_to_gnu (tree operand, Node_Id ch break; case N_Others_Choice: - this_test = integer_one_node; + this_test = boolean_true_node; break; default: Index: gcc/gcc/ada/gcc-interface/misc.c === --- gcc.orig/gcc/ada/gcc-interface/misc.c 2011-05-03 18:41:38.0 +0200 +++ gcc/gcc/ada/gcc-interface/misc.c2011-05-16 14:13:57.610535500 +0200 @@ -326,11 +326,13 @@ gnat_init (void) SET_TYPE_RM_MAX_VALUE (boolean_type_node, build_int_cst (boolean_type_node, 1)); SET_TYPE_RM_SIZE (boolean_type_node, bitsize_int (1)); + TYPE_PRECISION (boolean_type_node) = 1; build_common_tree_nodes_2 (0); sbitsize_one_node = sbitsize_int (1); sbitsize_unit_node = sbitsize_int (BITS_PER_UNIT); boolean_true_node = TYPE_MAX_VALUE (boolean_type_node); + boolean_false_node = TYPE_MIN_VALUE (boolean_type_node); ptr_void_type_node = build_pointer_type (void_type_node);