comparison gcc/fortran/convert.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Data type conversion 1 /* Data type conversion
2 Copyright (C) 1987-2017 Free Software Foundation, Inc. 2 Copyright (C) 1987-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
27 #include "coretypes.h" 27 #include "coretypes.h"
28 #include "tree.h" 28 #include "tree.h"
29 #include "fold-const.h" 29 #include "fold-const.h"
30 #include "convert.h" 30 #include "convert.h"
31 31
32 #include "gfortran.h"
33 #include "trans.h"
34 #include "trans-types.h"
35
32 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR, 36 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
33 or validate its data type for a GIMPLE `if' or `while' statement. 37 or validate its data type for a GIMPLE `if' or `while' statement.
34 38
35 The resulting type should always be `boolean_type_node'. */ 39 The resulting type should always be `logical_type_node'. */
36 40
37 static tree 41 static tree
38 truthvalue_conversion (tree expr) 42 truthvalue_conversion (tree expr)
39 { 43 {
40 switch (TREE_CODE (TREE_TYPE (expr))) 44 switch (TREE_CODE (TREE_TYPE (expr)))
41 { 45 {
42 case BOOLEAN_TYPE: 46 case BOOLEAN_TYPE:
43 if (TREE_TYPE (expr) == boolean_type_node) 47 if (TREE_TYPE (expr) == logical_type_node)
44 return expr; 48 return expr;
45 else if (COMPARISON_CLASS_P (expr)) 49 else if (COMPARISON_CLASS_P (expr))
46 { 50 {
47 TREE_TYPE (expr) = boolean_type_node; 51 TREE_TYPE (expr) = logical_type_node;
48 return expr; 52 return expr;
49 } 53 }
50 else if (TREE_CODE (expr) == NOP_EXPR) 54 else if (TREE_CODE (expr) == NOP_EXPR)
51 return fold_build1_loc (input_location, NOP_EXPR, 55 return fold_build1_loc (input_location, NOP_EXPR,
52 boolean_type_node, TREE_OPERAND (expr, 0)); 56 logical_type_node,
57 TREE_OPERAND (expr, 0));
53 else 58 else
54 return fold_build1_loc (input_location, NOP_EXPR, boolean_type_node, 59 return fold_build1_loc (input_location, NOP_EXPR,
60 logical_type_node,
55 expr); 61 expr);
56 62
57 case INTEGER_TYPE: 63 case INTEGER_TYPE:
58 if (TREE_CODE (expr) == INTEGER_CST) 64 if (TREE_CODE (expr) == INTEGER_CST)
59 return integer_zerop (expr) ? boolean_false_node : boolean_true_node; 65 return integer_zerop (expr) ? logical_false_node
66 : logical_true_node;
60 else 67 else
61 return fold_build2_loc (input_location, NE_EXPR, boolean_type_node, 68 return fold_build2_loc (input_location, NE_EXPR,
69 logical_type_node,
62 expr, build_int_cst (TREE_TYPE (expr), 0)); 70 expr, build_int_cst (TREE_TYPE (expr), 0));
63 71
64 default: 72 default:
65 gcc_unreachable (); 73 gcc_unreachable ();
66 } 74 }