Commit 403fd939 by Robert Dewar Committed by Samuel Tardieu

re PR ada/34287 (Simple Ada bug [Barnes' Silly])

2007-12-03  Robert Dewar <dewar@adacore.com>
            Samuel Tardieu  <sam@rfc1149.net>

        gcc/ada/
    	PR ada/34287
    	* sem_util.adb (Safe_To_Capture_Value): Do not capture values
    	of variables declared in a library-level package.
    
        gcc/testsuite/gnat.dg/
    	PR ada/34287
    	* check_elaboration_code.adb: New test.
    
    	* bug_elaboration_code.ads, bug_elaboration_code.adb: New support
    	files.

Co-Authored-By: Samuel Tardieu <sam@rfc1149.net>

From-SVN: r130582
parent 69b3331e
2007-12-03 Robert Dewar <dewar@adacore.com>
Samuel Tardieu <sam@rfc1149.net>
PR ada/34287
* sem_util.adb (Safe_To_Capture_Value): Do not capture values
of variables declared in a library-level package.
2007-12-02 Samuel Tardieu <sam@rfc1149.net> 2007-12-02 Samuel Tardieu <sam@rfc1149.net>
* clean.adb (Clean_Library_Directory): Use Empty_String'Access intead * clean.adb (Clean_Library_Directory): Use Empty_String'Access intead
...@@ -8583,12 +8583,16 @@ package body Sem_Util is ...@@ -8583,12 +8583,16 @@ package body Sem_Util is
-- Skip if volatile or aliased, since funny things might be going on in -- Skip if volatile or aliased, since funny things might be going on in
-- these cases which we cannot necessarily track. Also skip any variable -- these cases which we cannot necessarily track. Also skip any variable
-- for which an address clause is given, or whose address is taken. -- for which an address clause is given, or whose address is taken. Also
-- never capture value of library level variables (an attempt to do so
-- can occur in the case of package elaboration code).
if Treat_As_Volatile (Ent) if Treat_As_Volatile (Ent)
or else Is_Aliased (Ent) or else Is_Aliased (Ent)
or else Present (Address_Clause (Ent)) or else Present (Address_Clause (Ent))
or else Address_Taken (Ent) or else Address_Taken (Ent)
or else (Is_Library_Level_Entity (Ent)
and then Ekind (Ent) = E_Variable)
then then
return False; return False;
end if; end if;
......
2007-12-03 Robert Dewar <dewar@adacore.com>
Samuel Tardieu <sam@rfc1149.net>
PR ada/34287
* check_elaboration_code.adb: New test.
* bug_elaboration_code.ads, bug_elaboration_code.adb: New support
files.
2007-12-02 Paolo Carlini <pcarlini@suse.de> 2007-12-02 Paolo Carlini <pcarlini@suse.de>
PR c++/34061 PR c++/34061
package body Bug_Elaboration_Code is
procedure Increment_I is
begin
I := I + 1;
end Increment_I;
begin
I := 5;
Increment_I;
J := I;
end Bug_Elaboration_Code;
package Bug_Elaboration_Code is
pragma Elaborate_Body;
I : Integer;
J : Integer;
end Bug_Elaboration_Code;
-- { dg-do run }
with Bug_Elaboration_Code; use Bug_Elaboration_Code;
procedure Check_Elaboration_Code is
begin
if I /= J then
raise Program_Error;
end if;
end Check_Elaboration_Code;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment