aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/gimple-parser.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-07-01 13:36:05 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-07-01 13:36:05 +0000
commit69b5279e977593d656906288316ee03a8bf79c6a (patch)
treea5c20bc3e5adfbb743b300b6184a22a317bc5605 /gcc/c/gimple-parser.c
parent0c9c281da4651e8725429ff6709b48e3b2e62463 (diff)
downloadgcc-69b5279e977593d656906288316ee03a8bf79c6a.zip
gcc-69b5279e977593d656906288316ee03a8bf79c6a.tar.gz
gcc-69b5279e977593d656906288316ee03a8bf79c6a.tar.bz2
gimple-parser.c (c_parser_gimple_postfix_expression): Handle _Literal (char *) &"foo" for address literals pointing to STRING_CSTs.
2019-07-01 Richard Biener <rguenther@suse.de> c/ * gimple-parser.c (c_parser_gimple_postfix_expression): Handle _Literal (char *) &"foo" for address literals pointing to STRING_CSTs. * gcc.dg/gimplefe-42.c: New testcase. From-SVN: r272872
Diffstat (limited to 'gcc/c/gimple-parser.c')
-rw-r--r--gcc/c/gimple-parser.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c
index 275ad91..b2b364c 100644
--- a/gcc/c/gimple-parser.c
+++ b/gcc/c/gimple-parser.c
@@ -1596,17 +1596,22 @@ c_parser_gimple_postfix_expression (gimple_parser &parser)
}
else
{
- bool neg_p;
+ bool neg_p, addr_p;
if ((neg_p = c_parser_next_token_is (parser, CPP_MINUS)))
c_parser_consume_token (parser);
+ if ((addr_p = c_parser_next_token_is (parser, CPP_AND)))
+ c_parser_consume_token (parser);
tree val = c_parser_gimple_postfix_expression (parser).value;
if (! val
|| val == error_mark_node
- || ! CONSTANT_CLASS_P (val))
+ || ! CONSTANT_CLASS_P (val)
+ || (addr_p && TREE_CODE (val) != STRING_CST))
{
c_parser_error (parser, "invalid _Literal");
return expr;
}
+ if (addr_p)
+ val = build1 (ADDR_EXPR, type, val);
if (neg_p)
{
val = const_unop (NEGATE_EXPR, TREE_TYPE (val), val);