diff options
author | Steven Bosscher <steven@gcc.gnu.org> | 2012-03-06 19:51:42 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2012-03-06 19:51:42 +0000 |
commit | 87a60f68a9015f0de8e2377e2db09a6360754c8c (patch) | |
tree | 0595932f0c30a57f889841652942dd6cccd5019a /gcc/fortran/convert.c | |
parent | ca4adc913ddcaca116b48569ec97c7c7841f2a35 (diff) | |
download | gcc-87a60f68a9015f0de8e2377e2db09a6360754c8c.zip gcc-87a60f68a9015f0de8e2377e2db09a6360754c8c.tar.gz gcc-87a60f68a9015f0de8e2377e2db09a6360754c8c.tar.bz2 |
f95-lang.c (yyerror, yylex): Remove.
* f95-lang.c (yyerror, yylex): Remove.
(clear_binding_stack): Remove, fold into its only user.
(LANG_HOOKS_PRINT_IDENTIFIER): Do not re-define.
(ridpointers): Remove.
(gfc_eh_initialized_p): Make static.
(gfc_truthvalue_conversion): Move to convert.c.
(gfc_be_parse_file): Clear binding level stack when done.
(gfc_print_identifier): Remove.
(pushlevel): Remove ignored 'ignore' argument. Update all callers.
(poplevel): Remove unused 'reverse' argument. Update all callers.
(ggc_p): Remove.
(gfc_builtin_function): Make static. Do not attempt to make RTL for
builtin functions.
* convert.c (gfc_truthvalue_conversion): Moved here from f95-lang.c,
and made static.
* trans.h (pushlevel, poplevel): Adjust prototypes.
(gfc_truthvalue_conversion, gfc_builtin_function): Remove prototypes.
* trans-openmp.c: Update calls to pushlevel and poplevel.
* trans.c: Likewise.
* trans-decl.c: Likewise.
From-SVN: r185015
Diffstat (limited to 'gcc/fortran/convert.c')
-rw-r--r-- | gcc/fortran/convert.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/fortran/convert.c b/gcc/fortran/convert.c index 96874fa..be681a5 100644 --- a/gcc/fortran/convert.c +++ b/gcc/fortran/convert.c @@ -60,6 +60,50 @@ along with GCC; see the file COPYING3. If not see /* Subroutines of `convert'. */ +/* Prepare expr to be an argument of a TRUTH_NOT_EXPR, + or validate its data type for an `if' or `while' statement or ?..: exp. + + This preparation consists of taking the ordinary + representation of an expression expr and producing a valid tree + boolean expression describing whether expr is nonzero. We could + simply always do build_binary_op (NE_EXPR, expr, boolean_false_node, 1), + but we optimize comparisons, &&, ||, and !. + + The resulting type should always be `boolean_type_node'. + This is much simpler than the corresponding C version because we have a + distinct boolean type. */ + +static tree +gfc_truthvalue_conversion (tree expr) +{ + switch (TREE_CODE (TREE_TYPE (expr))) + { + case BOOLEAN_TYPE: + if (TREE_TYPE (expr) == boolean_type_node) + return expr; + else if (COMPARISON_CLASS_P (expr)) + { + TREE_TYPE (expr) = boolean_type_node; + return expr; + } + else if (TREE_CODE (expr) == NOP_EXPR) + return fold_build1_loc (input_location, NOP_EXPR, + boolean_type_node, TREE_OPERAND (expr, 0)); + else + return fold_build1_loc (input_location, NOP_EXPR, boolean_type_node, + expr); + + case INTEGER_TYPE: + if (TREE_CODE (expr) == INTEGER_CST) + return integer_zerop (expr) ? boolean_false_node : boolean_true_node; + else + return fold_build2_loc (input_location, NE_EXPR, boolean_type_node, + expr, build_int_cst (TREE_TYPE (expr), 0)); + + default: + internal_error ("Unexpected type in truthvalue_conversion"); + } +} /* Create an expression whose value is that of EXPR, converted to type TYPE. The TREE_TYPE of the value |