diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-09-14 22:16:56 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2012-09-14 22:16:56 +0100 |
commit | 9f33203d01759563ee11c708ef918aa65c1b5fe5 (patch) | |
tree | e2e2bde40ff1e0181abebbb3485df74d9578ddcf /gcc/c | |
parent | 9996a6d1b699ae3a438babd595df622c596b2c64 (diff) | |
download | gcc-9f33203d01759563ee11c708ef918aa65c1b5fe5.zip gcc-9f33203d01759563ee11c708ef918aa65c1b5fe5.tar.gz gcc-9f33203d01759563ee11c708ef918aa65c1b5fe5.tar.bz2 |
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
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index bd6ef8f..6aed2c3 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,12 @@ 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 * c-typeck.c (build_unary_op): Pass original argument of TRUTH_NOT_EXPR to c_objc_common_truthvalue_conversion, then remove diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 628857c..5b4ad28 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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); } |