# GNAT 15: (style) redundant parentheses \[-gnatyz\]

**URL:** https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395
**Category:** Help
**Tags:** gnat
**Created:** [May 6, 2026, 2:57pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395 "2026-05-06T14:57:22Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![saper](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/saper/32/910_2.png) [@saper](https://forum.ada-lang.io/u/saper)
#### Post date: [May 6, 2026, 2:57pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/1 "2026-05-06T14:57:23Z")

</div>

asn1scc generated code includes the [adasn1rtl.ads](https://github.com/esa/asn1scc/blob/bf364aac88b69ac6be9282027c1b70b8d6d95ce4/ADA_RTL2/src/adaasn1rtl.ads#L90-L95) file, which contains this:

```ada
   function Asn1Real_Equal (Left, Right : Asn1Real) return Boolean is
     (if Left = Right then True elsif Left = 0.0 then Right = 0.0
      elsif (Left > 0.0 and Right < 0.0) or (Left < 0.0 and Right > 0.0) then
        False
      elsif abs (Left) > abs (Right) then abs (Right) / abs (Left) >= 0.99999
      else abs (Left) / abs (Right) >= 0.99999);

```

GNAT 15.2.0 complains about the parentheses around `abs`

```ada
 /usr/local/gnat15/bin/gcc -c -x ada -gnatA -gnatwae -gnat2012 -g -gnatf -gnaty -gnatwa -gnatg -fstack-check -g -O0 -gnatwe -gnatwa -gnat2012 -gnatec=/tmp/GPR.64851/GNAT-TEMP-000003.TMP -gnatem=/tmp/GPR.64851/GNAT-TEMP-000004.TMP mainprogram.adb
adaasn1rtl.ads:94:17: (style) redundant parentheses [-gnatyz]
adaasn1rtl.ads:94:30: (style) redundant parentheses [-gnatyz]
adaasn1rtl.ads:94:47: (style) redundant parentheses [-gnatyz]
adaasn1rtl.ads:94:61: (style) redundant parentheses [-gnatyz]
adaasn1rtl.ads:95:16: (style) redundant parentheses [-gnatyz]
adaasn1rtl.ads:95:29: (style) redundant parentheses [-gnatyz]

```

why? it was ok under GNAT 14

I find it personally more readable with the parentheses.

---

<div class="post-metadata">

### Author: ![liampwll](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/l/b19c9b/32.png) [@liampwll](https://forum.ada-lang.io/u/liampwll)
#### Post date: [May 6, 2026, 3:23pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/2 "2026-05-06T15:23:11Z")

</div>

Why not just turn the warning off if you don’t care about it?

---

<div class="post-metadata">

### Author: ![AJ-Ianozi](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/aj-ianozi/32/39_2.png) [@AJ-Ianozi](https://forum.ada-lang.io/u/AJ-Ianozi)
#### Post date: [May 6, 2026, 3:47pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/3 "2026-05-06T15:47:53Z")

</div>

It looks like this is where it came from:

> **[\[gcc r15-6860\] ada: Remove redundant parentheses inside unary operators (cont.)](https://gcc.gnu.org/pipermail/gcc-cvs/2025-January/415762.html)**

With rationale being:

> GNAT already emits a style warning when redundant parentheses appear inside  
> logical and short-circuit operators. A similar warning will be soon emitted for  
> unary operators as well. This patch removes the redundant parentheses to avoid  
> build errors.

I’d probably end up doing something like this for readability:

```ada
   function Asn1Real_Equal (Left, Right : Asn1Real)
   return
      Boolean
   is
      (if Left = Right then
         True
       elsif Left = 0.0 then
         Right = 0.0
       elsif
         Left > 0.0 and Right < 0.0 or
         Left < 0.0 and Right > 0.0
       then
         False
       elsif abs (Left) > abs (Right) then
         abs (Right) / abs (Left) >= 0.99999
       else
         abs (Left) / abs (Right) >= 0.99999);

```

---

<div class="post-metadata">

### Author: ![saper](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/saper/32/910_2.png) [@saper](https://forum.ada-lang.io/u/saper)
#### Post date: [May 6, 2026, 4:09pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/4 "2026-05-06T16:09:10Z")

</div>

> [@AJ-Ianozi](#):
>
> ```ada
> Left > 0.0 and Right < 0.0 or
> Left < 0.0 and Right > 0.0
> 
> ```

Barnes 2022 writes,

> However, although the precedences are equal, **and** , **or** and **xor** cannot be mixed up in an expression without using parentheses (unlike + and - for instance).

indeed this gives

```
error: mixed logical operators in expression

```

> **[Expressions](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#I2454)**

AdaRM allows repeating

simple\_expression ::= [[unary\_adding\_operator](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-5.html#S0124)] [term](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0118) {[binary\_adding\_operator](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-5.html#S0123) [term](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0118)}

but not

expression ::=  
[relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116) { **and** [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116)} | [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116) { **and**  **then** [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116)}  
| [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116) { **or** [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116)} | [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116) { **or**  **else** [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116)}  
| [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116) { **xor** [relation](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-4.html#S0116)}

---

<div class="post-metadata">

### Author: ![AJ-Ianozi](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/aj-ianozi/32/39_2.png) [@AJ-Ianozi](https://forum.ada-lang.io/u/AJ-Ianozi)
#### Post date: [May 6, 2026, 4:59pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/5 "2026-05-06T16:59:46Z")

</div>

EDIT I clearly haven’t had enough coffee and it’s impacting my reading comprehension, I just realized that it’s complaining about using them around **abs**. Just disregard my response. I’ll leave my posts up as a monument to my shame.

---

<div class="post-metadata">

### Author: ![saper](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/saper/32/910_2.png) [@saper](https://forum.ada-lang.io/u/saper)
#### Post date: [May 6, 2026, 5:04pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/6 "2026-05-06T17:04:36Z")

</div>

No worries, we are all learning here. Your answer actually made me look up Ada RM, something I should be doing more often.

---

<div class="post-metadata">

### Author: ![saper](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/saper/32/910_2.png) [@saper](https://forum.ada-lang.io/u/saper)
#### Post date: [May 6, 2026, 5:13pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/7 "2026-05-06T17:13:08Z")

</div>

Now I understand that we have a concept of [highest preference operators](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-4-5-6.html) and therefore **abs**  **not** and **\*\*** need no parentheses. Thank you.

---

<div class="post-metadata">

### Author: ![dmitry-kazakov](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/dmitry-kazakov/32/522_2.png) [@dmitry-kazakov](https://forum.ada-lang.io/u/dmitry-kazakov)
#### Post date: [May 6, 2026, 5:28pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/8 "2026-05-06T17:28:31Z")

</div>

No operators need parenthesis unless association is forbidden. E.g. in `A + -B` or `1 ** +2`.

Precedence plays little role. Example: `1*-2` is illegal.

---

<div class="post-metadata">

### Author: ![AdaOrbit](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/adaorbit/32/879_2.png) [@AdaOrbit](https://forum.ada-lang.io/u/AdaOrbit)
#### Post date: [May 6, 2026, 6:26pm UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/9 "2026-05-06T18:26:25Z")

</div>

Side note: when building the bare\_runtime crate using gnat15 you also have to remove all of the redundant parentheses since style warnings are treated as errors for runtime systems. Guess how I know 🙃

---

<div class="post-metadata">

### Author: ![kevlar700](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/kevlar700/32/40_2.png) [@kevlar700](https://forum.ada-lang.io/u/kevlar700)
#### Post date: [May 7, 2026, 8:40am UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/10 "2026-05-07T08:40:56Z")

</div>

I would guess Ada does better here but I never rely on precedence (since before the Linux kernel rules added that you shouldn’t) which can be the cause of bugs through unnecessary complexity. I remove them when the Gnat compiler assures me it’s all good though with some knee jerk annoyance that’s fading.

---

<div class="post-metadata">

### Author: ![system](https://forum.ada-lang.io/uploads/default/original/1X/e625e7957e269cbf6d3128dab48a9e54fe3a9bdc.png) [@system](https://forum.ada-lang.io/u/system)
#### Post date: [May 8, 2026, 8:41am UTC](https://forum.ada-lang.io/t/gnat-15-style-redundant-parentheses-gnatyz/4395/11 "2026-05-08T08:41:17Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
