Commit 6da794e8 by Jason Merrill Committed by Jason Merrill

re PR c++/5857 (C++ duplicate_decls shouldn't use common_type)

        PR c++/5857
        * decl.c (duplicate_decls): Use merge_types instead of common_type.
        * typeck.c (common_type): Just hand off to
        type_after_usual_arithmetic_conversions and
        composite_pointer_type.
        (merge_types): New fn.
        (commonparms): Use it instead of common_type.
        (type_after_usual_arithmetic_conversions): Also handle COMPLEX_TYPE.
        (composite_pointer_type): Also handle attributes.
        * cp-tree.h: Declare merge_types.

From-SVN: r50820
parent b3b77add
2002-03-15 Jason Merrill <jason@redhat.com> 2002-03-15 Jason Merrill <jason@redhat.com>
PR c++/5857
* decl.c (duplicate_decls): Use merge_types instead of common_type.
* typeck.c (common_type): Just hand off to
type_after_usual_arithmetic_conversions and
composite_pointer_type.
(merge_types): New fn.
(commonparms): Use it instead of common_type.
(type_after_usual_arithmetic_conversions): Also handle COMPLEX_TYPE.
(composite_pointer_type): Also handle attributes.
* cp-tree.h: Declare merge_types.
* decl.c (make_rtl_for_nonlocal_decl): Also defer COMDAT * decl.c (make_rtl_for_nonlocal_decl): Also defer COMDAT
variables. variables.
* decl2.c (maybe_make_one_only): Also mark the decl as needed. * decl2.c (maybe_make_one_only): Also mark the decl as needed.
......
...@@ -4355,6 +4355,7 @@ extern tree pfn_from_ptrmemfunc PARAMS ((tree)); ...@@ -4355,6 +4355,7 @@ extern tree pfn_from_ptrmemfunc PARAMS ((tree));
extern tree type_after_usual_arithmetic_conversions PARAMS ((tree, tree)); extern tree type_after_usual_arithmetic_conversions PARAMS ((tree, tree));
extern tree composite_pointer_type PARAMS ((tree, tree, tree, tree, extern tree composite_pointer_type PARAMS ((tree, tree, tree, tree,
const char*)); const char*));
extern tree merge_types PARAMS ((tree, tree));
extern tree check_return_expr PARAMS ((tree)); extern tree check_return_expr PARAMS ((tree));
#define cp_build_binary_op(code, arg1, arg2) \ #define cp_build_binary_op(code, arg1, arg2) \
build_binary_op(code, arg1, arg2, 1) build_binary_op(code, arg1, arg2, 1)
......
...@@ -3515,16 +3515,16 @@ duplicate_decls (newdecl, olddecl) ...@@ -3515,16 +3515,16 @@ duplicate_decls (newdecl, olddecl)
tree newtype; tree newtype;
/* Merge the data types specified in the two decls. */ /* Merge the data types specified in the two decls. */
newtype = common_type (TREE_TYPE (newdecl), TREE_TYPE (olddecl)); newtype = merge_types (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
/* If common_type produces a non-typedef type, just use the old type. */ /* If merge_types produces a non-typedef type, just use the old type. */
if (TREE_CODE (newdecl) == TYPE_DECL if (TREE_CODE (newdecl) == TYPE_DECL
&& newtype == DECL_ORIGINAL_TYPE (newdecl)) && newtype == DECL_ORIGINAL_TYPE (newdecl))
newtype = oldtype; newtype = oldtype;
if (TREE_CODE (newdecl) == VAR_DECL) if (TREE_CODE (newdecl) == VAR_DECL)
DECL_THIS_EXTERN (newdecl) |= DECL_THIS_EXTERN (olddecl); DECL_THIS_EXTERN (newdecl) |= DECL_THIS_EXTERN (olddecl);
/* Do this after calling `common_type' so that default /* Do this after calling `merge_types' so that default
parameters don't confuse us. */ parameters don't confuse us. */
else if (TREE_CODE (newdecl) == FUNCTION_DECL else if (TREE_CODE (newdecl) == FUNCTION_DECL
&& (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl)) && (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl))
......
// PR c++/5857
// This testcase failed because during duplicate_decls the type was promoted
// to int.
// { dg-do compile }
typedef char baz;
extern const char foo[];
const baz foo[] = "xyz";
const char bar[] = "abc";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment