diff mbox

Remove true and false ARI checks now that we use stdbool.h.

Message ID 1423756577-10959-1-git-send-email-mjw@redhat.com
State New
Headers show

Commit Message

Mark Wielaard Feb. 12, 2015, 3:56 p.m. UTC
I saw new ari warnings related to the usage of true and false in
utils.c (producer_is_gcc). Since we now use stdbool.h (and might switch to
C++ soon) usage of true and false is obviously fine. Remove these checks.

gdb/ChangeLog:

	* contrib/ari/gdb_ari.sh: Remove checks for "true" and "false".
---

Comments

Doug Evans Feb. 12, 2015, 8:03 p.m. UTC | #1
On Thu, Feb 12, 2015 at 7:56 AM, Mark Wielaard <mjw@redhat.com> wrote:
> I saw new ari warnings related to the usage of true and false in
> utils.c (producer_is_gcc). Since we now use stdbool.h (and might switch to
> C++ soon) usage of true and false is obviously fine. Remove these checks.
>
> gdb/ChangeLog:
>
>         * contrib/ari/gdb_ari.sh: Remove checks for "true" and "false".
> ---
> diff --git a/gdb/contrib/ari/gdb_ari.sh b/gdb/contrib/ari/gdb_ari.sh
> index b868a17..52d8ab1 100644
> --- a/gdb/contrib/ari/gdb_ari.sh
> +++ b/gdb/contrib/ari/gdb_ari.sh
> @@ -1145,26 +1145,6 @@ Do not use `boolean'\'',  use `int'\'' instead"
>      }
>  }
>
> -BEGIN { doc["false"] = "\
> -Definitely do not use `false'\'' in boolean expressions"
> -    category["false"] = ari_regression
> -}
> -/(^|[^_[:alnum:]])false([^_[:alnum:]]|$)/ {
> -    if (is_yacc_or_lex == 0) {
> -       fail("false")
> -    }
> -}
> -
> -BEGIN { doc["true"] = "\
> -Do not try to use `true'\'' in boolean expressions"
> -    category["true"] = ari_regression
> -}
> -/(^|[^_[:alnum:]])true([^_[:alnum:]]|$)/ {
> -    if (is_yacc_or_lex == 0) {
> -       fail("true")
> -    }
> -}
> -
>  # Typedefs that are either redundant or can be reduced to `struct
>  # type *''.
>  # Must be placed before if assignment otherwise ARI exceptions

Fine by me.
CC'ing Pierre (ARI maintainer) in case I missed something.

Regarding the "boolean" check (immediately preceeding false/true).
It currently says "use int instead".
Should we change that to bool?
Pierre Muller Feb. 12, 2015, 11:08 p.m. UTC | #2
Hi all,

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Doug Evans
> Envoyé : jeudi 12 février 2015 21:04
> À : Mark Wielaard
> Cc : gdb-patches; muller@sourceware.org
> Objet : Re: [PATCH] Remove true and false ARI checks now that we use
> stdbool.h.
> 
> On Thu, Feb 12, 2015 at 7:56 AM, Mark Wielaard <mjw@redhat.com> wrote:
> > I saw new ari warnings related to the usage of true and false in
> > utils.c (producer_is_gcc). Since we now use stdbool.h (and might
> switch to
> > C++ soon) usage of true and false is obviously fine. Remove these
> checks.
> >
> > gdb/ChangeLog:
> >
> >         * contrib/ari/gdb_ari.sh: Remove checks for "true" and
> "false".
> > ---
> > diff --git a/gdb/contrib/ari/gdb_ari.sh b/gdb/contrib/ari/gdb_ari.sh
> > index b868a17..52d8ab1 100644
> > --- a/gdb/contrib/ari/gdb_ari.sh
> > +++ b/gdb/contrib/ari/gdb_ari.sh
> > @@ -1145,26 +1145,6 @@ Do not use `boolean'\'',  use `int'\''
> instead"
> >      }
> >  }
> >
> > -BEGIN { doc["false"] = "\
> > -Definitely do not use `false'\'' in boolean expressions"
> > -    category["false"] = ari_regression
> > -}
> > -/(^|[^_[:alnum:]])false([^_[:alnum:]]|$)/ {
> > -    if (is_yacc_or_lex == 0) {
> > -       fail("false")
> > -    }
> > -}
> > -
> > -BEGIN { doc["true"] = "\
> > -Do not try to use `true'\'' in boolean expressions"
> > -    category["true"] = ari_regression
> > -}
> > -/(^|[^_[:alnum:]])true([^_[:alnum:]]|$)/ {
> > -    if (is_yacc_or_lex == 0) {
> > -       fail("true")
> > -    }
> > -}
> > -
> >  # Typedefs that are either redundant or can be reduced to `struct
> >  # type *''.
> >  # Must be placed before if assignment otherwise ARI exceptions
> 
> Fine by me.
> CC'ing Pierre (ARI maintainer) in case I missed something.

  It seems indeed logical to allow false/true 
 if we are on the road to C++ sources...

> Regarding the "boolean" check (immediately preceeding false/true).
> It currently says "use int instead".
> Should we change that to bool?

  My knowledge of C++ is less than minimal,
for those who don't remember:
I basically learned C in GDB sources to be able to 
add and maintain pascal language support,
which is of course my language of predilection...

  Just to explain that I do not know what the default
Boolean type is for C++.

Anyhow, I suppose that we can safely accept Mark's
patch regarding the false and true rule removal,
unless someone wants to advocate why we should still
refrain from using them.

Pierre Muller
as ARI maintainer.
Mark Wielaard Feb. 16, 2015, 10:57 a.m. UTC | #3
On Fri, 2015-02-13 at 00:08 +0100, Pierre Muller wrote:
>   My knowledge of C++ is less than minimal,
> for those who don't remember:
> I basically learned C in GDB sources to be able to 
> add and maintain pascal language support,
> which is of course my language of predilection...
> 
>   Just to explain that I do not know what the default
> Boolean type is for C++.

The default C++ boolean type is bool. The C99 boolean type is _Bool.
Earlier C versions don't have a standard boolean type, but old practice
in gdb was to use int. Now you always just #include <stdbool.h> which
defines true, false and the right typedef for bool for C (and does
nothing for C++). So you should only see 'bool' used.

> Anyhow, I suppose that we can safely accept Mark's
> patch regarding the false and true rule removal

Thanks, pushed.

Cheers,

Mark
diff mbox

Patch

diff --git a/gdb/contrib/ari/gdb_ari.sh b/gdb/contrib/ari/gdb_ari.sh
index b868a17..52d8ab1 100644
--- a/gdb/contrib/ari/gdb_ari.sh
+++ b/gdb/contrib/ari/gdb_ari.sh
@@ -1145,26 +1145,6 @@  Do not use `boolean'\'',  use `int'\'' instead"
     }
 }
 
-BEGIN { doc["false"] = "\
-Definitely do not use `false'\'' in boolean expressions"
-    category["false"] = ari_regression
-}
-/(^|[^_[:alnum:]])false([^_[:alnum:]]|$)/ {
-    if (is_yacc_or_lex == 0) {
-       fail("false")
-    }
-}
-
-BEGIN { doc["true"] = "\
-Do not try to use `true'\'' in boolean expressions"
-    category["true"] = ari_regression
-}
-/(^|[^_[:alnum:]])true([^_[:alnum:]]|$)/ {
-    if (is_yacc_or_lex == 0) {
-       fail("true")
-    }
-}
-
 # Typedefs that are either redundant or can be reduced to `struct
 # type *''.
 # Must be placed before if assignment otherwise ARI exceptions