2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-25 10:10:51 +08:00

re PR c/54552 (Cast to pointer to VLA crash the compiler)

c:
	PR c/54552
	* c-typeck.c (c_cast_expr): When casting to a type requiring
	C_MAYBE_CONST_EXPR to be created, pass the inner expression to
	c_fully_fold first.

testsuite:
	* gcc.c-torture/compile/pr54552-1.c: New test.

From-SVN: r191313
This commit is contained in:
Joseph Myers 2012-09-14 22:16:56 +01:00 committed by Joseph Myers
parent 9996a6d1b6
commit 9f33203d01
4 changed files with 24 additions and 1 deletions
gcc
c
testsuite
ChangeLog
gcc.c-torture/compile

@ -1,3 +1,10 @@
2012-09-14 Joseph Myers <joseph@codesourcery.com>
PR c/54552
* c-typeck.c (c_cast_expr): When casting to a type requiring
C_MAYBE_CONST_EXPR to be created, pass the inner expression to
c_fully_fold first.
2012-09-14 Joseph Myers <joseph@codesourcery.com>
PR c/54103

@ -4779,8 +4779,11 @@ c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
ret = build_c_cast (loc, type, expr);
if (type_expr)
{
bool inner_expr_const = true;
ret = c_fully_fold (ret, require_constant_value, &inner_expr_const);
ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
C_MAYBE_CONST_EXPR_NON_CONST (ret) = !type_expr_const;
C_MAYBE_CONST_EXPR_NON_CONST (ret) = !(type_expr_const
&& inner_expr_const);
SET_EXPR_LOCATION (ret, loc);
}

@ -1,3 +1,8 @@
2012-09-14 Joseph Myers <joseph@codesourcery.com>
PR c/54552
* gcc.c-torture/compile/pr54552-1.c: New test.
2012-09-14 Marc Glisse <marc.glisse@inria.fr>
PR c++/54427

@ -0,0 +1,8 @@
void
f (void)
{
unsigned n = 10;
typedef double T[n];
(double (*)[n])((unsigned char (*)[sizeof (T)]){ 0 });
}