Index: c-convert.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-convert.c,v retrieving revision 1.20 diff -c -p -r1.20 c-convert.c *** c-convert.c 4 Feb 2004 19:15:16 -0000 1.20 --- c-convert.c 9 Mar 2004 19:51:30 -0000 *************** Software Foundation, 59 Temple Place - S *** 34,39 **** --- 34,40 ---- #include "convert.h" #include "c-common.h" #include "langhooks.h" + #include "c-tree.h" #include "toplev.h" /* Change of width--truncation and extension of integers or reals-- *************** convert (tree type, tree expr) *** 114,119 **** --- 115,128 ---- return fold (convert_to_complex (type, e)); if (code == VECTOR_TYPE) return fold (convert_to_vector (type, e)); + if (code == RECORD_TYPE || code == ENUMERAL_TYPE || code == UNION_TYPE) + { + tree t2 = TREE_TYPE (expr); + if (code == TREE_CODE (t2) + && !same_translation_unit_p (type, t2) + && tagged_types_tu_compatible_p (type, t2, 0)) + return e; + } error ("conversion to non-scalar type requested"); return error_mark_node; Index: c-tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v retrieving revision 1.141 diff -c -p -r1.141 c-tree.h *** c-tree.h 29 Feb 2004 23:43:20 -0000 1.141 --- c-tree.h 9 Mar 2004 19:51:31 -0000 *************** enum { *** 256,261 **** --- 256,263 ---- COMPARE_STRICT = 0 }; + extern int same_translation_unit_p (tree, tree); + extern int tagged_types_tu_compatible_p (tree, tree, int); extern tree require_complete_type (tree); extern int comptypes (tree, tree, int); extern tree c_size_in_bytes (tree); Index: c-typeck.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v retrieving revision 1.283 diff -c -p -r1.283 c-typeck.c *** c-typeck.c 8 Mar 2004 21:56:32 -0000 1.283 --- c-typeck.c 9 Mar 2004 19:51:31 -0000 *************** Software Foundation, 59 Temple Place - S *** 51,58 **** static int missing_braces_mentioned; static tree qualify_type (tree, tree); - static int same_translation_unit_p (tree, tree); - static int tagged_types_tu_compatible_p (tree, tree, int); static int comp_target_types (tree, tree, int); static int function_types_compatible_p (tree, tree, int); static int type_lists_compatible_p (tree, tree, int); --- 51,56 ---- *************** comp_target_types (tree ttl, tree ttr, i *** 617,623 **** If the CONTEXT chain ends in a null, that type's context is still being parsed, so if two types have context chains ending in null, they're in the same translation unit. */ ! static int same_translation_unit_p (tree t1, tree t2) { while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL) --- 615,621 ---- If the CONTEXT chain ends in a null, that type's context is still being parsed, so if two types have context chains ending in null, they're in the same translation unit. */ ! int same_translation_unit_p (tree t1, tree t2) { while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL) *************** struct tagged_tu_seen { *** 650,655 **** --- 648,655 ---- const struct tagged_tu_seen * next; tree t1; tree t2; + int isEnum; + int enumMatched; }; /* Can they be compatible with each other? We choose to break the *************** static const struct tagged_tu_seen * tag *** 663,669 **** units are being compiled. See C99 6.2.7 paragraph 1 for the exact rules. */ ! static int tagged_types_tu_compatible_p (tree t1, tree t2, int flags) { tree s1, s2; --- 663,669 ---- units are being compiled. See C99 6.2.7 paragraph 1 for the exact rules. */ ! int tagged_types_tu_compatible_p (tree t1, tree t2, int flags) { tree s1, s2;