diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1c1cf9b4849..9fb4ce894da 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,25 @@ +2011-08-03 Ed Schonberg + + * sem_ch6.adb: guard against error nodes in return statements. + +2011-08-03 Arnaud Charlet + + * errout.adb (Error_Msg_Internal): the main unit has not been read yet, + a warning can only appear on a configuration file, so emit warning + without further checks. + +2011-08-03 Arnaud Charlet + + * s-interr.ads: add overriding keyword. + +2011-08-03 Geert Bosch + + * exp_attr.adb: Fix minor typo. + +2011-08-03 Ed Schonberg + + * par-ch4.adb: improve error recovery. + 2011-08-03 Emmanuel Briot * prj-part.adb, prj-part.ads, prj-makr.adb, prj-pars.adb, prj-conf.adb, diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index e7940579cde..49068ef2387 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -751,6 +751,12 @@ package body Errout is if In_Extended_Main_Source_Unit (Sptr) then null; + -- If the main unit has not been read yet. the warning must be on + -- a configuration file: gnat.adc or user-defined. + + elsif No (Cunit (Main_Unit)) then + null; + -- If the flag location is not in the main extended source unit, then -- we want to eliminate the warning, unless it is in the extended -- main code unit and we want warnings on the instance. diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index a2c2bcc8d4c..686bf04289a 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -4998,7 +4998,7 @@ package body Exp_Attr is -- Value -- ----------- - -- Value attribute is handled in separate unti Exp_Imgv + -- Value attribute is handled in separate unit Exp_Imgv when Attribute_Value => Exp_Imgv.Expand_Value_Attribute (N); diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb index 4c25c3ca649..8d45b2c3cb9 100644 --- a/gcc/ada/par-ch4.adb +++ b/gcc/ada/par-ch4.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -606,8 +606,18 @@ package body Ch4 is raise Error_Resync; elsif Token /= Tok_Right_Paren then - T_Right_Paren; - raise Error_Resync; + if Token = Tok_Arrow then + + -- This may be an aggregate that is missing a qualification + + Error_Msg_SC + ("context of aggregate must be a qualified expression"); + raise Error_Resync; + + else + T_Right_Paren; + raise Error_Resync; + end if; else Scan; -- past right paren diff --git a/gcc/ada/s-interr.ads b/gcc/ada/s-interr.ads index 3b66f067e53..1d936f5a5f0 100644 --- a/gcc/ada/s-interr.ads +++ b/gcc/ada/s-interr.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -256,6 +256,7 @@ package System.Interrupts is (Object : access Static_Interrupt_Protection) return Boolean; -- Returns True + overriding procedure Finalize (Object : in out Static_Interrupt_Protection); -- Restore previous handlers as required by C.3.1(12) then call -- Finalize (Protection). diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index d487921ad0f..11c807b5c3b 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -628,8 +628,19 @@ package body Sem_Ch6 is if Nkind (N) = N_Simple_Return_Statement then Expr := Expression (N); - Analyze_And_Resolve (Expr, R_Type); - Check_Limited_Return (Expr); + + -- Guard against a malformed expression. The parser may have + -- tried to recover but the node is not analyzable. + + if Nkind (Expr) = N_Error then + Set_Etype (Expr, Any_Type); + Expander_Mode_Save_And_Set (False); + return; + + else + Analyze_And_Resolve (Expr, R_Type); + Check_Limited_Return (Expr); + end if; -- RETURN only allowed in SPARK is as the last statement function