[Ada] Don't fail a front-end assertion if errors have already been detected
diff mbox series

Message ID 20190918083945.GA145140@adacore.com
State New
Headers show
Series
  • [Ada] Don't fail a front-end assertion if errors have already been detected
Related show

Commit Message

Pierre-Marie de Rodat Sept. 18, 2019, 8:39 a.m. UTC
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.

Patch
diff mbox series

--- 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