2011-08-02 Jason Merrill <jason@redhat.com>
+ PR c++/49577
+ * typeck2.c (check_narrowing): Check unsigned mismatch.
+ * semantics.c (finish_compound_literal): check_narrowing.
+
PR c++/49593
* pt.c (find_parameter_packs_r): Handle CONSTRUCTOR.
&& check_array_initializer (NULL_TREE, type, compound_literal))
return error_mark_node;
compound_literal = reshape_init (type, compound_literal, complain);
+ if (cxx_dialect >= cxx0x && SCALAR_TYPE_P (type)
+ && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal))
+ check_narrowing (type, compound_literal);
if (TREE_CODE (type) == ARRAY_TYPE
&& TYPE_DOMAIN (type) == NULL_TREE)
{
else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
&& CP_INTEGRAL_TYPE_P (type))
{
- if (TYPE_PRECISION (type) < TYPE_PRECISION (ftype)
+ if ((TYPE_PRECISION (type) < TYPE_PRECISION (ftype)
+ || TYPE_UNSIGNED (type) != TYPE_UNSIGNED (ftype))
&& (TREE_CODE (init) != INTEGER_CST
|| !int_fits_type_p (init, type)))
ok = false;
2011-08-02 Jason Merrill <jason@redhat.com>
+ PR c++/49577
+ * g++.dg/cpp0x/initlist5.C: Add additional cases.
+
PR c++/49593
* g++.dg/cpp0x/variadic115.C: New.
float fa[] = { d, 1.1 }; // { dg-error "narrowing conversion of 'd'" }
constexpr double d2 = 1.1;
float fa2[] = { d2, 1.1 };
+
+// PR c++/49577
+unsigned u{ -1 }; // { dg-error "narrowing" }
+char c = char{ u }; // { dg-error "narrowing" }
{ -3 C -4 C -5 }, { -6 C -7 C -8 C -2 C -1 C 1 C 2 C INT_MAX C INT_MIN })
T(17, unsigned int, (x >= -8U && x <= -3U) || x == -2U || x == -1U || x == 0 || x == 1 || x == 2,
{ -8U C -7U C -6U C -5U C -4U C -3U C -2U C -1U C 0 C 1 C 2 },
- { -9U C -10U C 3 C 4 C 12 C -54U C INT_MAX C INT_MIN })
+ { -9U C -10U C 3 C 4 C 12 C -54U C INT_MAX C (unsigned int)INT_MIN })
T(18, int, (x >= -8 && x <= -3) || x == -2 || x == -1 || x == 0 || x == 1 || x == 2,
{ -8 C -7 C -6 C -5 C -4 C -3 C -2 C -1 C 0 C 1 C 2 },
{ -9 C -10 C 3 C 4 C 12 C -54 C INT_MAX C INT_MIN })