https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102605

--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 6 Oct 2021, aldyh at redhat dot com wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102605
> 
> --- Comment #5 from Aldy Hernandez <aldyh at redhat dot com> ---
> > > BTW, the __MEM_REF output from the dumps does not work in -fgimple either.
> > > More errors.
> >
> > Can you share an example?
> 
> This is from gcc.c-torture/execute/961125-1.c compiled with -fgimple:
> 
> char * begfield (int tab, char * ptr, char * lim, int sword, int schar);
> 
> int __GIMPLE (ssa)
> main ()
> {
>   char * lim;
>   char * s;
>   char * _1;
> 
>   __BB(2):
>   _1 = begfield (58, ":ab", &__MEM <char[4]> ((void *)":ab" + _Literal
> (void *) 3), 1, 1);

OK, here we're eliding the & before the ":ab" in duming, so it should
read

  _1 = begfield (58, ":ab", &__MEM <char[4]> ((void *)&":ab" + _Literal 
(void *) 3), 1, 1);

>   if (_1 != &__MEM <char[4]> ((void *)":ab" + _Literal (void *) 2))
>     goto __BB3;

Likewise here, and the patch I'm testing should fix the missing _Literal:

  if (_1 != _Literal (char *) &__MEM <char[4]> ((void *)&":ab" + _Literal 
(void *) 2))

then there needs to be an adjustment to the C frontend to allow
MEM_REFs as lvalue:

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index f9eb0e5176f..efe70511b91 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -4969,6 +4969,8 @@ lvalue_p (const_tree ref)
       return true;

     case INDIRECT_REF:
+    case MEM_REF:
+    case TARGET_MEM_REF:
     case ARRAY_REF:
     case VAR_DECL:
     case PARM_DECL:

Then the code is accepted.

Btw, please report cases where -gimple doesn't produce valid GIMPLE FE
inputs (OK, there are known cases with mangled symbol names when
passes create temporaries whose name includes a '.' for example...)

Reply via email to