This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] ada-lang, possible_user_operator_p, null pointer
- From: Joel Brobecker <brobecker at adacore dot com>
- To: msnyder at sonic dot net
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 13 Aug 2007 21:30:53 -0700
- Subject: Re: [PATCH] ada-lang, possible_user_operator_p, null pointer
- References: <19577.12.7.175.2.1186864998.squirrel@webmail.sonic.net>
> 2007-08-11 Michael Snyder <msnyder@access-company.com>
>
> * ada-lang.c (possible_user_operator_p): Guard against NULL.
This is another case where I'd prefer to have the check for a NULL
type moved to the top of the function. But I'm having a tough time
determining how this might actually happen. So I'd like to sit on it
for a little longer before we proceed.
> Also, I'm not sure what the CONCAT operator is, but is it
> possible that the OR at the beginning of the same line
> should be an AND? Just checking...
The BINOP_CONCAT operator corresponds to the "&" binop operator, which
allows us to concatenate two arrays into one. For instance, you may
have some code like this:
Hello : constant String := "Hello";
There : constant String := "there";
Hello_There : constant String := Hello & " " & There;
In terms of the condition, it's kind of confusing, since the logic is
sort of backwards as far as my brain seems to work. But I think the
condition is actually correct: If you have an array on each side,
then use the pre-defined operator. So if you negate this condition,
if either lhs *or* rhs are not arrays, then...
> Index: ada-lang.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ada-lang.c,v
> retrieving revision 1.100
> diff -p -r1.100 ada-lang.c
> *** ada-lang.c 6 Aug 2007 20:07:44 -0000 1.100
> --- ada-lang.c 11 Aug 2007 20:39:20 -0000
> *************** possible_user_operator_p (enum exp_opcod
> *** 3536,3542 ****
> ((TYPE_CODE (type0) != TYPE_CODE_ARRAY
> && (TYPE_CODE (type0) != TYPE_CODE_PTR
> || TYPE_CODE (TYPE_TARGET_TYPE (type0)) != TYPE_CODE_ARRAY))
> ! || (TYPE_CODE (type1) != TYPE_CODE_ARRAY
> && (TYPE_CODE (type1) != TYPE_CODE_PTR
> || (TYPE_CODE (TYPE_TARGET_TYPE (type1))
> != TYPE_CODE_ARRAY))));
> --- 3536,3542 ----
> ((TYPE_CODE (type0) != TYPE_CODE_ARRAY
> && (TYPE_CODE (type0) != TYPE_CODE_PTR
> || TYPE_CODE (TYPE_TARGET_TYPE (type0)) != TYPE_CODE_ARRAY))
> ! || (type1 != NULL && TYPE_CODE (type1) != TYPE_CODE_ARRAY
> && (TYPE_CODE (type1) != TYPE_CODE_PTR
> || (TYPE_CODE (TYPE_TARGET_TYPE (type1))
> != TYPE_CODE_ARRAY))));
--
Joel