Mercurial > hg > CbC > CbC_gcc
comparison gcc/c/c-convert.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Language-level data type conversion for GNU C. | 1 /* Language-level data type conversion for GNU C. |
2 Copyright (C) 1987-2018 Free Software Foundation, Inc. | 2 Copyright (C) 1987-2020 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 |
113 && current_function_decl != NULL_TREE | 113 && current_function_decl != NULL_TREE |
114 && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE | 114 && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE |
115 && COMPLETE_TYPE_P (type)) | 115 && COMPLETE_TYPE_P (type)) |
116 { | 116 { |
117 expr = save_expr (expr); | 117 expr = save_expr (expr); |
118 expr = c_fully_fold (expr, false, NULL); | |
118 tree check = ubsan_instrument_float_cast (loc, type, expr); | 119 tree check = ubsan_instrument_float_cast (loc, type, expr); |
119 expr = fold_build1 (FIX_TRUNC_EXPR, type, expr); | 120 expr = fold_build1 (FIX_TRUNC_EXPR, type, expr); |
120 if (check == NULL_TREE) | 121 if (check == NULL_TREE) |
121 return expr; | 122 return expr; |
122 return fold_build2 (COMPOUND_EXPR, TREE_TYPE (expr), check, expr); | 123 return fold_build2 (COMPOUND_EXPR, TREE_TYPE (expr), check, expr); |
144 case COMPLEX_TYPE: | 145 case COMPLEX_TYPE: |
145 ret = convert_to_complex (type, e); | 146 ret = convert_to_complex (type, e); |
146 goto maybe_fold; | 147 goto maybe_fold; |
147 | 148 |
148 case VECTOR_TYPE: | 149 case VECTOR_TYPE: |
149 ret = convert_to_vector (type, e); | 150 if (gnu_vector_type_p (type) |
150 goto maybe_fold; | 151 || gnu_vector_type_p (TREE_TYPE (e)) |
152 /* Allow conversions between compatible non-GNU vector types | |
153 when -flax-vector-conversions is passed. The whole purpose | |
154 of the option is to bend the normal type rules and accept | |
155 nonconforming code. */ | |
156 || (flag_lax_vector_conversions | |
157 && VECTOR_TYPE_P (TREE_TYPE (e)) | |
158 && vector_types_convertible_p (type, TREE_TYPE (e), false))) | |
159 { | |
160 ret = convert_to_vector (type, e); | |
161 goto maybe_fold; | |
162 } | |
163 break; | |
151 | 164 |
152 case RECORD_TYPE: | 165 case RECORD_TYPE: |
153 case UNION_TYPE: | 166 case UNION_TYPE: |
154 if (lang_hooks.types_compatible_p (type, TREE_TYPE (expr))) | 167 if (lang_hooks.types_compatible_p (type, TREE_TYPE (expr))) |
155 return e; | 168 return e; |