diff options
author | Richard Biener <rguenther@suse.de> | 2021-10-05 14:18:09 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-10-05 16:37:39 +0200 |
commit | d4f6dbe18374385b8199ca3d6121e37a1189b589 (patch) | |
tree | 8e01be04ec6f9a594838cb39051fd6307f08274b /gcc/c/gimple-parser.c | |
parent | f3930418cb82000fae3cb4e98e870428800cf295 (diff) | |
download | gcc-d4f6dbe18374385b8199ca3d6121e37a1189b589.zip gcc-d4f6dbe18374385b8199ca3d6121e37a1189b589.tar.gz gcc-d4f6dbe18374385b8199ca3d6121e37a1189b589.tar.bz2 |
Allow more kinds of invariant addresses in GIMPLE FE
The gimple FE is too restrictive in what it accepts as
literals, the following makes it also accept &a[10] for example.
2021-10-05 Richard Biener <rguenther@suse.de>
PR c/102605
gcc/c/
* gimple-parser.c (c_parser_gimple_postfix_expression):
Accept more address _Literals.
gcc/testsuite/
* gcc.dg/gimplefe-46.c: New testcase.
Diffstat (limited to 'gcc/c/gimple-parser.c')
-rw-r--r-- | gcc/c/gimple-parser.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index c8d9db6..c43ee38 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1622,16 +1622,20 @@ c_parser_gimple_postfix_expression (gimple_parser &parser) tree val = c_parser_gimple_postfix_expression (parser).value; if (! val || val == error_mark_node - || (!CONSTANT_CLASS_P (val) - && !(addr_p - && (TREE_CODE (val) == STRING_CST - || DECL_P (val))))) + || (!CONSTANT_CLASS_P (val) && !addr_p)) { c_parser_error (parser, "invalid _Literal"); return expr; } if (addr_p) - val = build1 (ADDR_EXPR, type, val); + { + val = build1 (ADDR_EXPR, type, val); + if (!is_gimple_invariant_address (val)) + { + c_parser_error (parser, "invalid _Literal"); + return expr; + } + } if (neg_p) { val = const_unop (NEGATE_EXPR, TREE_TYPE (val), val); |