diff options
author | Richard Biener <rguenther@suse.de> | 2017-06-19 15:01:13 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-06-19 15:01:13 +0000 |
commit | 343ae898b17490d15c98f711ffcb04c88cca9235 (patch) | |
tree | ef6963983505b5fc27f730d9f530a778279acca3 /gcc/c/gimple-parser.c | |
parent | 9787269815559a63fbbda58b35137f832a612984 (diff) | |
download | gcc-343ae898b17490d15c98f711ffcb04c88cca9235.zip gcc-343ae898b17490d15c98f711ffcb04c88cca9235.tar.gz gcc-343ae898b17490d15c98f711ffcb04c88cca9235.tar.bz2 |
re PR bootstrap/80887 (gnat bootstrap fails at s-regpat.o: raised STORAGE_ERROR : stack overflow or erroneous memory access)
2017-06-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/80887
c/
* gimple-parser.c (c_parser_gimple_postfix_expression): Handle
negated _Literals to parse _Literal (int) -1.
* tree-ssa-sccvn.c (mprts_hook_cnt): New global.
(vn_lookup_simplify_result): Allow only mprts_hook_cnt succesful
simplified lookups, then reset mprts_hook.
(vn_nary_build_or_lookup_1): Set mprts_hook_cnt to 9 before
simplifying.
(try_to_simplify): Likewise.
* gcc.dg/tree-ssa/pr80887.c: New testcase.
From-SVN: r249373
Diffstat (limited to 'gcc/c/gimple-parser.c')
-rw-r--r-- | gcc/c/gimple-parser.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 4a55904..22f58f4 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -850,7 +850,7 @@ c_parser_gimple_postfix_expression (c_parser *parser) } else if (strcmp (IDENTIFIER_POINTER (id), "_Literal") == 0) { - /* _Literal '(' type-name ')' number */ + /* _Literal '(' type-name ')' [ '-' ] constant */ c_parser_consume_token (parser); tree type = NULL_TREE; if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) @@ -862,15 +862,27 @@ c_parser_gimple_postfix_expression (c_parser *parser) c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); } + bool neg_p; + if ((neg_p = c_parser_next_token_is (parser, CPP_MINUS))) + c_parser_consume_token (parser); tree val = c_parser_gimple_postfix_expression (parser).value; if (! type || ! val || val == error_mark_node - || TREE_CODE (val) != INTEGER_CST) + || ! CONSTANT_CLASS_P (val)) { c_parser_error (parser, "invalid _Literal"); return expr; } + if (neg_p) + { + val = const_unop (NEGATE_EXPR, TREE_TYPE (val), val); + if (! val) + { + c_parser_error (parser, "invalid _Literal"); + return expr; + } + } expr.value = fold_convert (type, val); return expr; } |