diff 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
line wrap: on
line diff
--- a/gcc/c/c-convert.c	Thu Oct 25 07:37:49 2018 +0900
+++ b/gcc/c/c-convert.c	Thu Feb 13 11:34:05 2020 +0900
@@ -1,5 +1,5 @@
 /* Language-level data type conversion for GNU C.
-   Copyright (C) 1987-2018 Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -115,6 +115,7 @@
 	  && COMPLETE_TYPE_P (type))
 	{
 	  expr = save_expr (expr);
+	  expr = c_fully_fold (expr, false, NULL);
 	  tree check = ubsan_instrument_float_cast (loc, type, expr);
 	  expr = fold_build1 (FIX_TRUNC_EXPR, type, expr);
 	  if (check == NULL_TREE)
@@ -146,8 +147,20 @@
       goto maybe_fold;
 
     case VECTOR_TYPE:
-      ret = convert_to_vector (type, e);
-      goto maybe_fold;
+      if (gnu_vector_type_p (type)
+	  || gnu_vector_type_p (TREE_TYPE (e))
+	  /* Allow conversions between compatible non-GNU vector types
+	     when -flax-vector-conversions is passed.  The whole purpose
+	     of the option is to bend the normal type rules and accept
+	     nonconforming code.  */
+	  || (flag_lax_vector_conversions
+	      && VECTOR_TYPE_P (TREE_TYPE (e))
+	      && vector_types_convertible_p (type, TREE_TYPE (e), false)))
+	{
+	  ret = convert_to_vector (type, e);
+	  goto maybe_fold;
+	}
+      break;
 
     case RECORD_TYPE:
     case UNION_TYPE: