public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Jeff Law <law@redhat.com>
Cc: gcc-patches@gcc.gnu.org, Phil Muldoon <pmuldoon@redhat.com>,
	       Alexandre Oliva <aoliva@redhat.com>
Subject: Re: ping: [gcc patch] libcc1: '@' GDB array operator
Date: Sat, 30 May 2015 12:12:00 -0000	[thread overview]
Message-ID: <20150530094717.GA1473@host1.jankratochvil.net> (raw)
In-Reply-To: <55694DCB.1000402@redhat.com>

On Sat, 30 May 2015 07:42:35 +0200, Jeff Law wrote:
> We're still digging out a
> bit from the patches queued while preparing for the gcc5 release.
                                                      gcc6

> So I guess at some level it's not clear to me why we need to support the @
> operator in libcc1.  So perhaps starting with a justification for
> wanting/needed that capability would be helpful.

It is not a simple /@[0-9]+$/ regex, the expression can be for example
	(*vararray@(3+1))
Parentheses still could be parsed by GDB, though.

But a statement expression could not be parsed by GDB:
	compile print ({ __auto_type ptr=vararray+1; *ptr@3; })
But I have found now it does not work - it prints just a pointer, not an array
- due to:
1	int main (void) { typeof (({ int a[]={1,2,3,4,5}; a; })) *ptr_type; return 0; }
(gdb) ptype ptr_type
type = int **
It is in DWARF really just:
	DW_TAG_pointer_type -> DW_TAG_pointer_type -> DW_TAG_base_type

With future C++ support it also would not work:
1	int array[]={1,2,3,4,5};
2	auto copy(array);
(gdb) ptype copy
type = int *


I have found now GDB can do also
	*vararray@somevar
while this GCC patch cannot:
	gdb command line:1:39: error: second parameter of operator '@' requires constant integer
I did not realize that myself before.  I do not think there is an easy fix for
the GCC patch, is it?  But I do not think it matters too much, IMO GDB users
usually put there just constant numbers, at least I do.


So all the currently working cases can be implemented also just in GDB.
I still find more correct to do it in GCC than to implement new kind of
expression parsing in GDB - which the 'compile' project tries to avoid.
But sure up to you whether it fits in GCC or not.


> As for the patch itself, you noted you weren't sure if copy_node was right,
> it would help if you'd describe what problem you were having that's solved
> by copying the node. I wonder if you should be building up a node from
> scratch here.

I have removed it and it works.  But there are many statements I do not
understand and I only guess they should be copying similar code around.
The block of code can be replaced just by:
    case ATSIGN_EXPR:
      op0 = TREE_OPERAND (expr, 0);
      op1 = TREE_OPERAND (expr, 1);
      ret = op0;
      TREE_TYPE (ret) = build_array_type_nelts (TREE_TYPE (op0),
                                                tree_to_uhwi (op1));
      TREE_READONLY (ret) = TREE_READONLY (expr);
      TREE_SIDE_EFFECTS (ret) = TREE_SIDE_EFFECTS (expr);
      TREE_THIS_VOLATILE (ret) = TREE_THIS_VOLATILE (expr);
      goto out;
which also works for me.  But I guess one could find some countercases for this
simplified block.


> In general, please use C style comments rather than C++.

Done.


Jan

  reply	other threads:[~2015-05-30  9:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27 16:36 Jan Kratochvil
2015-04-17 15:17 ` ping: " Jan Kratochvil
2015-05-30  8:33   ` Jeff Law
2015-05-30 12:12     ` Jan Kratochvil [this message]
2015-05-31 19:52       ` [gcc patchv2] " Jan Kratochvil
2015-06-03 15:09       ` ping: [gcc patch] " Jeff Law
2015-06-03 15:34         ` Tom Tromey
2015-06-03 16:31           ` Jeff Law
2015-06-03 18:38             ` Manuel López-Ibáñez
2015-06-03 18:55               ` Tom Tromey
2015-06-03 21:08         ` Jan Kratochvil
2015-06-04  7:36           ` Manuel López-Ibáñez
2015-06-04  8:17             ` Jan Kratochvil
2015-06-04  8:42               ` Manuel López-Ibáñez
2015-06-04  8:56                 ` Jan Kratochvil
2015-06-04  9:15                 ` Jakub Jelinek
2015-06-04 13:36                   ` Jan Kratochvil
2015-06-04 14:03               ` Jeff Law
2015-06-04 14:37                 ` Jan Kratochvil
2015-06-04 14:43                   ` Jeff Law

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=20150530094717.GA1473@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=aoliva@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=pmuldoon@redhat.com \
    /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: link
Be 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).