Commit 3aeb3655 by Eric Christopher Committed by Eric Christopher

c-typeck.c (common_type): Don't lose type qualifiers when creating new variants.

2004-06-02  Eric Christopher  <echristo@redhat.com>

        * c-typeck.c (common_type): Don't lose type qualifiers
        when creating new variants.

2004-06-02  Eric Christopher  <echristo@redhat.com>

        * gcc.c-torture/compile/20040602-1.c: New.

From-SVN: r82577
parent 03a4c969
2004-06-02 Eric Christopher <echristo@redhat.com>
* c-typeck.c (common_type): Don't lose type qualifiers
when creating new variants.
2004-06-02 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-optimization/14042
......
......@@ -279,45 +279,64 @@ common_type (tree t1, tree t2)
/* Same precision. Prefer long longs to longs to ints when the
same precision, following the C99 rules on integer type rank
(which are equivalent to the C90 rules for C90 types). */
(which are equivalent to the C90 rules for C90 types).
Make sure that we don't lose the type qualifications when
creating the new variant. */
if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node
|| TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node)
return build_type_attribute_variant (long_long_unsigned_type_node,
attributes);
{
t1 = build_qualified_type (long_long_unsigned_type_node,
TYPE_QUALS (t1));
return build_type_attribute_variant (t1, attributes);
}
if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node
|| TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node)
{
tree ntype;
if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
t1 = long_long_unsigned_type_node;
ntype = long_long_unsigned_type_node;
else
t1 = long_long_integer_type_node;
return build_type_attribute_variant (t1, attributes);
ntype = long_long_integer_type_node;
ntype = build_qualified_type (ntype, TYPE_QUALS (t1));
return build_type_attribute_variant (ntype, attributes);
}
if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
|| TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
return build_type_attribute_variant (long_unsigned_type_node,
attributes);
{
t1 = build_qualified_type (long_unsigned_type_node,
TYPE_QUALS (t1));
return build_type_attribute_variant (t1, attributes);
}
if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
|| TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
{
tree ntype;
/* But preserve unsignedness from the other type,
since long cannot hold all the values of an unsigned int. */
if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
t1 = long_unsigned_type_node;
ntype = long_unsigned_type_node;
else
t1 = long_integer_type_node;
return build_type_attribute_variant (t1, attributes);
ntype = long_integer_type_node;
ntype = build_qualified_type (ntype, TYPE_QUALS (t1));
return build_type_attribute_variant (ntype, attributes);
}
/* Likewise, prefer long double to double even if same size. */
if (TYPE_MAIN_VARIANT (t1) == long_double_type_node
|| TYPE_MAIN_VARIANT (t2) == long_double_type_node)
return build_type_attribute_variant (long_double_type_node,
attributes);
{
t1 = build_qualified_type (long_double_type_node,
TYPE_QUALS (t1));
return build_type_attribute_variant (t1, attributes);
}
/* Otherwise prefer the unsigned one. */
......@@ -506,7 +525,8 @@ comptypes (tree type1, tree type2, int flags)
/* Different classes of types can't be compatible. */
if (TREE_CODE (t1) != TREE_CODE (t2)) return 0;
if (TREE_CODE (t1) != TREE_CODE (t2))
return 0;
/* Qualifiers must match. */
......
2004-06-02 Eric Christopher <echristo@redhat.com>
* gcc.c-torture/compile/20040602-1.c: New.
2004-06-02 Andrew Pinski <pinskia@physics.uc.edu>
* g++.dg/tree-ssa/ssa-sra-1.C: Fix comment.
......
/* Test type qualifiers. These should as equal types. */
extern volatile unsigned long foo;
typedef unsigned long ulong;
extern volatile ulong foo;
volatile ulong foo;
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