diff options
author | Mark Shinwell <shinwell@codesourcery.com> | 2007-01-08 09:25:07 +0000 |
---|---|---|
committer | Mark Shinwell <shinwell@gcc.gnu.org> | 2007-01-08 09:25:07 +0000 |
commit | 00c8e9f61310542dd3948933fab738970303b9d1 (patch) | |
tree | 3d101600d4d4d5150a485676365aecf8a6e1dbd7 /gcc/c-common.c | |
parent | 46e3b90f7e326c672c4ecddf5287f603a89d03ef (diff) | |
download | gcc-00c8e9f61310542dd3948933fab738970303b9d1.zip gcc-00c8e9f61310542dd3948933fab738970303b9d1.tar.gz gcc-00c8e9f61310542dd3948933fab738970303b9d1.tar.bz2 |
c.opt: Add -flax-vector-conversions.
gcc/
* c.opt: Add -flax-vector-conversions.
* c-typeck.c (convert_for_assignment): Pass flag to
vector_types_convertible_p to allow emission of note.
(digest_init): Likewise.
(comptypes_internal): Use vector_types_convertible_p.
* c-opts.c: Handle -flax-vector-conversions.
* c-common.c (flag_lax_vector_conversions): New.
(vector_types_convertible_p): Unless -flax-vector conversions
has been passed, disallow conversions between vectors with
differing numbers of subparts and/or element types. If such
a conversion is disallowed, possibly emit a note on the first
occasion only to inform the user of -flax-vector-conversions.
The new last argument specifies this.
* c-common.h (flag_lax_vector_conversions): New.
(vector_types_convertible_p): Add extra argument.
* config/i386/i386.c (ix86_init_mmx_sse_builtins): Use
char_type_node for V*QI type vectors.
* config/rs6000/rs6000-c.c (altivec_overloaded_builtins):
Update to satisfy new typechecking rules.
* config/rs6000/altivec.h (vec_cmple): Use vec_cmpge.
* doc/invoke.texi (C Dialect Options): Document
-flax-vector-conversions.
gcc/cp/
* call.c (standard_conversion): Pass flag to
vector_types_convertible_p to disallow emission of note.
* typeck.c (convert_for_assignment): Pass flag to
vector_types_convertible_p to allow emission of note.
(ptr_reasonably_similar): Pass flag to vector_types_convertible_p
to disallow emission of note.
gcc/testsuite/
* gcc.target/i386/20020531-1.c: Use "char" not "unsigned char"
in __v8qi typedef.
* gcc.target/powerpc/altivec-vec-merge.c (foo): Add casts.
* gcc.dg/simd-1.c: Update dg-error directives to reflect new
compiler behaviour.
* gcc.dg/simd-5.c: Likewise.
* gcc.dg/simd-6.c: Likewise.
* g++.dg/conversion/simd1.C: Likewise.
* g++.dg/conversion/simd3.C: Likewise.
* g++.dg/ext/attribute-test-2.C (data): Add "vs" member.
(main): Use it.
From-SVN: r120572
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 8fb9541..ef4c2e8 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -254,6 +254,10 @@ int flag_short_double; int flag_short_wchar; +/* Nonzero means allow implicit conversions between vectors with + differing numbers of subparts and/or differing element types. */ +int flag_lax_vector_conversions; + /* Nonzero means allow Microsoft extensions without warnings or errors. */ int flag_ms_extensions; @@ -1078,19 +1082,40 @@ check_main_parameter_types (tree decl) pedwarn ("%q+D takes only zero or two arguments", decl); } - -/* Nonzero if vector types T1 and T2 can be converted to each other - without an explicit cast. */ -int -vector_types_convertible_p (tree t1, tree t2) -{ - return targetm.vector_opaque_p (t1) - || targetm.vector_opaque_p (t2) - || (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)) - && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE || - TYPE_PRECISION (t1) == TYPE_PRECISION (t2)) - && INTEGRAL_TYPE_P (TREE_TYPE (t1)) - == INTEGRAL_TYPE_P (TREE_TYPE (t2))); +/* True if vector types T1 and T2 can be converted to each other + without an explicit cast. If EMIT_LAX_NOTE is true, and T1 and T2 + can only be converted with -flax-vector-conversions yet that is not + in effect, emit a note telling the user about that option if such + a note has not previously been emitted. */ +bool +vector_types_convertible_p (tree t1, tree t2, bool emit_lax_note) +{ + static bool emitted_lax_note = false; + bool convertible_lax = + targetm.vector_opaque_p (t1) + || targetm.vector_opaque_p (t2) + || (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)) + && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE || + TYPE_PRECISION (t1) == TYPE_PRECISION (t2)) + && INTEGRAL_TYPE_P (TREE_TYPE (t1)) + == INTEGRAL_TYPE_P (TREE_TYPE (t2))); + + if (!convertible_lax || flag_lax_vector_conversions) + return convertible_lax; + + if (TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2) + && comptypes (TREE_TYPE (t1), TREE_TYPE (t2))) + return true; + + if (emit_lax_note && !emitted_lax_note) + { + emitted_lax_note = true; + inform ("use -flax-vector-conversions to permit " + "conversions between vectors with differing " + "element types or numbers of subparts"); + } + + return false; } /* Warns if the conversion of EXPR to TYPE may alter a value. |