From: jakub Date: Tue, 5 Mar 2019 09:03:50 +0000 (+0000) Subject: PR bootstrap/89560 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bf0f78c4674d95d1253dd6feefea913a3a454df4;p=thirdparty%2Fgcc.git PR bootstrap/89560 * fold-const.c (fold_checksum_tree): Don't use fixed size buffer, instead alloca it only when needed with the needed size. * g++.dg/other/pr89560.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269386 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 54c736b340be..788ce54da7f9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2019-03-05 Jakub Jelinek + PR bootstrap/89560 + * fold-const.c (fold_checksum_tree): Don't use fixed size buffer, + instead alloca it only when needed with the needed size. + PR tree-optimization/89570 * match.pd (vec_cond into cond_op simplification): Guard with vectorized_internal_fn_supported_p test and #if GIMPLE. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8989fc7827e7..571566aa6bca 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12112,7 +12112,7 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, { const tree_node **slot; enum tree_code code; - union tree_node buf; + union tree_node *buf; int i, len; recursive_label: @@ -12127,11 +12127,13 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, && HAS_DECL_ASSEMBLER_NAME_P (expr)) { /* Allow DECL_ASSEMBLER_NAME and symtab_node to be modified. */ - memcpy ((char *) &buf, expr, tree_size (expr)); - SET_DECL_ASSEMBLER_NAME ((tree)&buf, NULL); - buf.decl_with_vis.symtab_node = NULL; - buf.base.nowarning_flag = 0; - expr = (tree) &buf; + size_t sz = tree_size (expr); + buf = XALLOCAVAR (union tree_node, sz); + memcpy ((char *) buf, expr, sz); + SET_DECL_ASSEMBLER_NAME ((tree) buf, NULL); + buf->decl_with_vis.symtab_node = NULL; + buf->base.nowarning_flag = 0; + expr = (tree) buf; } else if (TREE_CODE_CLASS (code) == tcc_type && (TYPE_POINTER_TO (expr) @@ -12143,8 +12145,10 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, { /* Allow these fields to be modified. */ tree tmp; - memcpy ((char *) &buf, expr, tree_size (expr)); - expr = tmp = (tree) &buf; + size_t sz = tree_size (expr); + buf = XALLOCAVAR (union tree_node, sz); + memcpy ((char *) buf, expr, sz); + expr = tmp = (tree) buf; TYPE_CONTAINS_PLACEHOLDER_INTERNAL (tmp) = 0; TYPE_POINTER_TO (tmp) = NULL; TYPE_REFERENCE_TO (tmp) = NULL; @@ -12160,9 +12164,11 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, { /* Allow TREE_NO_WARNING to be set. Perhaps we shouldn't allow that and change builtins.c etc. instead - see PR89543. */ - memcpy ((char *) &buf, expr, tree_size (expr)); - buf.base.nowarning_flag = 0; - expr = (tree) &buf; + size_t sz = tree_size (expr); + buf = XALLOCAVAR (union tree_node, sz); + memcpy ((char *) buf, expr, sz); + buf->base.nowarning_flag = 0; + expr = (tree) buf; } md5_process_bytes (expr, tree_size (expr), ctx); if (CODE_CONTAINS_STRUCT (code, TS_TYPED)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9d770c96f15..b9bfeced8867 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-03-05 Jakub Jelinek + PR bootstrap/89560 + * g++.dg/other/pr89560.C: New test. + PR tree-optimization/89570 * gcc.dg/pr89570.c: New test. diff --git a/gcc/testsuite/g++.dg/other/pr89560.C b/gcc/testsuite/g++.dg/other/pr89560.C new file mode 100644 index 000000000000..deb983969d75 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr89560.C @@ -0,0 +1,13 @@ +// PR bootstrap/89560 +// { dg-do compile } + +#define TEN(x) x##0, x##1, x##2, x##3, x##4, x##5, x##6, x##7, x##8, x##9, +#define HUNDRED(x) TEN(x##0) TEN(x##1) TEN(x##2) TEN(x##3) TEN(x##4) \ + TEN(x##5) TEN(x##6) TEN(x##7) TEN(x##8) TEN(x##9) +int foo (int, ...); + +int +bar () +{ + return (foo (HUNDRED (1) 0)); +}