public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4187] Allow more kinds of invariant addresses in GIMPLE FE Date: Tue, 5 Oct 2021 14:37:46 +0000 (GMT) [thread overview] Message-ID: <20211005143746.3A32E3858410@sourceware.org> (raw) https://gcc.gnu.org/g:d4f6dbe18374385b8199ca3d6121e37a1189b589 commit r12-4187-gd4f6dbe18374385b8199ca3d6121e37a1189b589 Author: Richard Biener <rguenther@suse.de> Date: Tue Oct 5 14:18:09 2021 +0200 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. Diff: --- gcc/c/gimple-parser.c | 14 +++++++++----- gcc/testsuite/gcc.dg/gimplefe-46.c | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index c8d9db61f0a..c43ee38a2cf 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); diff --git a/gcc/testsuite/gcc.dg/gimplefe-46.c b/gcc/testsuite/gcc.dg/gimplefe-46.c new file mode 100644 index 00000000000..fb91f7d2a90 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-46.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +char global[10]; + +void bar (void); + +void __GIMPLE (ssa) +foo (char * p) +{ + __BB(2): + if (p_2(D) == _Literal (char *)&global[2]) + goto __BB3; + else + goto __BB4; + + __BB(3): + bar (); + goto __BB4; + + __BB(4): + return; +}
reply other threads:[~2021-10-05 14:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211005143746.3A32E3858410@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).