Re: [rfc][00/37] Eliminate builtin_type_ macros

Joel Brobecker
2008-09-10T16:25:47Z

[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]

> > Sure! I don't know what this didn't cross my mind earlier, I guess
> > I was in a bit of a crunch... Will do that tomorrow (I'm also planning
> > on submitting a bunch of patches tomorrow as well, if things go as
> > planned - so that'll be a good time for that).
>
> OK, thanks!

OK, I ended up checking in both patches (there was simply too much
confusion on the second one, so it was simpler if I just change
the use of builtin_type_int into builtin_type_int32). Hopefully,
this should clear the way for you to commit your series of patches!

2008-09-10 Joel Brobecker <brobecker@adacore.com>

* ada-lang.c (ada_evaluate_subexp) [BINOP_ADD, BINOP_SUB]:
Add special handling for pointer types.

2008-09-10 Joel Brobecker <brobecker@adacore.com>

* ada-lang.c (ada_evaluate_subexp) [OP_ATR_SIZE]: Use
archecture-neutral builtin_type_int32 instead of builtin_type_int.

As I said, using int32 is not completely ideal, but should be good
enough in practice. If someone ever hits that limitation, I'll think
about writing a function that returns a type that's big enough to hold
a given LONGEST/ULONGEST...

Actual patches attached. Tested on x86-linux by running the gdb.ada
testcases.

Cheers,
--
Joel

[-- Attachment #2: 01-ptrdiff.diff --]
[-- Type: text/plain, Size: 1409 bytes --]

Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -p -r1.156 -r1.157
--- ada-lang.c 10 Sep 2008 09:47:39 -0000 1.156
+++ ada-lang.c 10 Sep 2008 16:12:35 -0000 1.157
@@ -8497,6 +8497,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) + value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
@@ -8514,6 +8518,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) - value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))

[-- Attachment #3: 02-size_atr.diff --]
[-- Type: text/plain, Size: 807 bytes --]

Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.157
diff -u -p -r1.157 ada-lang.c
--- ada-lang.c 10 Sep 2008 16:12:35 -0000 1.157
+++ ada-lang.c 10 Sep 2008 16:19:19 -0000
@@ -9074,9 +9074,9 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type_int, not_lval);
+ return value_zero (builtin_type_int32, not_lval);
else
- return value_from_longest (builtin_type_int,
+ return value_from_longest (builtin_type_int32,
TARGET_CHAR_BIT
* TYPE_LENGTH (value_type (arg1)));