Message ID | 1445831362-18789-2-git-send-email-simon.marchi@polymtl.ca |
---|---|
State | New, archived |
Headers |
Received: (qmail 20119 invoked by alias); 26 Oct 2015 03:49:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20089 invoked by uid 89); 26 Oct 2015 03:49:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp.electronicbox.net Received: from smtp.electronicbox.net (HELO smtp.electronicbox.net) (96.127.255.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 03:49:24 +0000 Received: from simark.lan. (cable-192.222.137.139.electronicbox.net [192.222.137.139]) by smtp.electronicbox.net (Postfix) with ESMTP id 17A59440E8A; Sun, 25 Oct 2015 23:49:23 -0400 (EDT) From: Simon Marchi <simon.marchi@polymtl.ca> To: gdb-patches@sourceware.org Cc: Simon Marchi <simon.marchi@polymtl.ca> Subject: [PATCH c++ 12/12] ada-lang.h: Add cast in GROW_VECT Date: Sun, 25 Oct 2015 23:49:22 -0400 Message-Id: <1445831362-18789-2-git-send-email-simon.marchi@polymtl.ca> In-Reply-To: <1445831362-18789-1-git-send-email-simon.marchi@polymtl.ca> References: <1445831362-18789-1-git-send-email-simon.marchi@polymtl.ca> |
Commit Message
Simon Marchi
Oct. 26, 2015, 3:49 a.m. UTC
The assignment requires a cast in C++. gdb/ChangeLog: * ada-lang.h (GROW_VECT): Add cast. --- gdb/ada-lang.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 10/26/2015 03:49 AM, Simon Marchi wrote: > The assignment requires a cast in C++. > > gdb/ChangeLog: > > * ada-lang.h (GROW_VECT): Add cast. > --- > gdb/ada-lang.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h > index 62896f1..32c4b55 100644 > --- a/gdb/ada-lang.h > +++ b/gdb/ada-lang.h > @@ -147,7 +147,7 @@ struct ada_task_info > least M objects, updating V and S as necessary. */ > > #define GROW_VECT(v, s, m) \ > - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); > + if ((s) < (m)) (v) = (typeof (v)) grow_vect (v, &(s), m, sizeof *(v)); > typeof in C is a GCC extension. Probably not all compilers support it. In my branch I just have: #define GROW_VECT(v, s, m) \ - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); + if ((s) < (m)) (v) = (char *) grow_vect (v, &(s), m, sizeof *(v)); Because that works for all current uses of GROW_VECT. If we wanted to make this work for random types, then we could add a type parameter to the GROW_VECT macro, like: - #define GROW_VECT(v, s, m) \ - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); + #define GROW_VECT(t, v, s, m) \ + if ((s) < (m)) (v) = (t *) grow_vect (v, &(s), m, sizeof *(v)); Not sure it's worth it though. It then raises the question of "why not replace this home grown GROW_VECT stuff with a VEC instead". Thanks, Pedro Alves
On 26/10/15 12:50 PM, Pedro Alves wrote: > On 10/26/2015 03:49 AM, Simon Marchi wrote: >> The assignment requires a cast in C++. >> >> gdb/ChangeLog: >> >> * ada-lang.h (GROW_VECT): Add cast. >> --- >> gdb/ada-lang.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h >> index 62896f1..32c4b55 100644 >> --- a/gdb/ada-lang.h >> +++ b/gdb/ada-lang.h >> @@ -147,7 +147,7 @@ struct ada_task_info >> least M objects, updating V and S as necessary. */ >> >> #define GROW_VECT(v, s, m) \ >> - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); >> + if ((s) < (m)) (v) = (typeof (v)) grow_vect (v, &(s), m, sizeof *(v)); >> > > typeof in C is a GCC extension. Probably not all compilers support it. > > In my branch I just have: > > #define GROW_VECT(v, s, m) \ > - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); > + if ((s) < (m)) (v) = (char *) grow_vect (v, &(s), m, sizeof *(v)); > > Because that works for all current uses of GROW_VECT. > > If we wanted to make this work for random types, then we could add > a type parameter to the GROW_VECT macro, like: > > - #define GROW_VECT(v, s, m) \ > - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); > + #define GROW_VECT(t, v, s, m) \ > + if ((s) < (m)) (v) = (t *) grow_vect (v, &(s), m, sizeof *(v)); > > Not sure it's worth it though. It then raises the question of > "why not replace this home grown GROW_VECT stuff with a VEC instead". > > Thanks, > Pedro Alves I thought about changing it for a proper VEC, but it's not really in the scope of the C++ changes. If I side-track on things like this, it will take an eternity! And I feel that at this moment, it would be a risk of introducing bugs without added value. Is it ok if I simply push your version that adds the (char *) in the macro? It seems like the most efficient fix given the situation.
On 10/27/2015 02:34 AM, Simon Marchi wrote: > On 26/10/15 12:50 PM, Pedro Alves wrote: >> typeof in C is a GCC extension. Probably not all compilers support it. >> >> In my branch I just have: >> >> #define GROW_VECT(v, s, m) \ >> - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); >> + if ((s) < (m)) (v) = (char *) grow_vect (v, &(s), m, sizeof *(v)); >> >> Because that works for all current uses of GROW_VECT. >> >> If we wanted to make this work for random types, then we could add >> a type parameter to the GROW_VECT macro, like: >> >> - #define GROW_VECT(v, s, m) \ >> - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); >> + #define GROW_VECT(t, v, s, m) \ >> + if ((s) < (m)) (v) = (t *) grow_vect (v, &(s), m, sizeof *(v)); >> >> Not sure it's worth it though. It then raises the question of >> "why not replace this home grown GROW_VECT stuff with a VEC instead". > I thought about changing it for a proper VEC, but it's not really in the scope of > the C++ changes. If I side-track on things like this, it will take an eternity! > And I feel that at this moment, it would be a risk of introducing bugs without > added value. > > Is it ok if I simply push your version that adds the (char *) in the macro? It > seems like the most efficient fix given the situation. It's certainly fine with me. Thanks, Pedro Alves
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 62896f1..32c4b55 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -147,7 +147,7 @@ struct ada_task_info least M objects, updating V and S as necessary. */ #define GROW_VECT(v, s, m) \ - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); + if ((s) < (m)) (v) = (typeof (v)) grow_vect (v, &(s), m, sizeof *(v)); extern void *grow_vect (void *, size_t *, size_t, int);