public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Don't emit style errors when parens are required
@ 2021-05-05  8:20 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-05  8:20 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ghjuvan Lacambre

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

GNAT currently emits style errors for declare expressions in conditions
even though their parens are required. This commit fixes that.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* par-ch5.adb (P_Condition): Check if expression is declare
	expression.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 965 bytes --]

diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb
--- a/gcc/ada/par-ch5.adb
+++ b/gcc/ada/par-ch5.adb
@@ -1299,17 +1299,16 @@ package body Ch5 is
 
          return Cond;
 
-      --  Otherwise check for redundant parentheses
-
-      --  If the condition is a conditional or a quantified expression, it is
-      --  parenthesized in the context of a condition, because of a separate
-      --  syntax rule.
+      --  Otherwise check for redundant parentheses but do not emit messages
+      --  about expressions that require parentheses (e.g. conditional,
+      --  quantified or declaration expressions).
 
       else
          if Style_Check
            and then
              Paren_Count (Cond) >
                (if Nkind (Cond) in N_Case_Expression
+                                 | N_Expression_With_Actions
                                  | N_If_Expression
                                  | N_Quantified_Expression
                 then 1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-05  8:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05  8:20 [Ada] Don't emit style errors when parens are required Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).