public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Don't fail a front-end assertion if errors have already been detected
@ 2019-09-18  8:40 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-09-18  8:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Steve Baird

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

In sem_eval.adb, we have an assertion that the type of a "null" literal
is an access type. It turns out that this assertion can fail when
processing an illegal program, e.g. one that contains something like
"Integer'(null)".  This leads to differences in the compiler's generated
output for such tests depending on whether assertions are/aren't
enabled; in particular, the "compilation abandoned due to previous
error" message generated in Comperr.Compiler_Abort. In order to avoid
these differences, we change the assertion so that it does not fail if
errors have already been posted on the given node.

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

2019-09-18  Steve Baird  <baird@adacore.com>

gcc/ada/

	* sem_eval.adb (Expr_Value): Do not fail "the type of a null
	literal must be an access type" assertion if errors have already
	been posted on the given node.

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

--- gcc/ada/sem_eval.adb
+++ gcc/ada/sem_eval.adb
@@ -4278,7 +4278,8 @@ package body Sem_Eval is
       --  The NULL access value
 
       elsif Kind = N_Null then
-         pragma Assert (Is_Access_Type (Underlying_Type (Etype (N))));
+         pragma Assert (Is_Access_Type (Underlying_Type (Etype (N)))
+           or else Error_Posted (N));
          Val := Uint_0;
 
       --  Character literal


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

only message in thread, other threads:[~2019-09-18  8:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18  8:40 [Ada] Don't fail a front-end assertion if errors have already been detected 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).