Commit 8f7770f9 by Robert Dewar Committed by Arnaud Charlet

sem_ch13.adb (Analyze_Attribute_Definition_Clause, [...]): Check for restriction…

sem_ch13.adb (Analyze_Attribute_Definition_Clause, [...]): Check for restriction No_Implementation_Attributes if in Ada 95 mode.

2007-04-20  Robert Dewar  <dewar@adacore.com>
	    Arnaud Charlet  <charlet@adacore.com>

	* sem_ch13.adb (Analyze_Attribute_Definition_Clause, case Stream_Size):
	Check for restriction No_Implementation_Attributes if in Ada 95 mode.
	(Storage_Pool): Do not crash when RE_Stack_Bounded_Pool is not available
	(Analyze_Attribute_Definition_Clause [External_Tag]): Generate error
	message when using a VM, since this attribute is not supported.
	(Analyze_Record_Representation_Clause): Give unrepped component warnings

	* usage.adb: Add new warning for renaming of function return objects
	Indicate that -gnatwp and -gnatwP concern front-end inlining
	Add line for -gnatyg
	Add usage information for -gnatw.c/C

From-SVN: r125449
parent 8909e1ed
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -31,6 +31,7 @@ with Errout; use Errout; ...@@ -31,6 +31,7 @@ with Errout; use Errout;
with Exp_Tss; use Exp_Tss; with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util; with Exp_Util; use Exp_Util;
with Lib; use Lib; with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists; with Nlists; use Nlists;
with Nmake; use Nmake; with Nmake; use Nmake;
with Opt; use Opt; with Opt; use Opt;
...@@ -1052,7 +1053,13 @@ package body Sem_Ch13 is ...@@ -1052,7 +1053,13 @@ package body Sem_Ch13 is
("static string required for tag name!", Nam); ("static string required for tag name!", Nam);
end if; end if;
Set_Has_External_Tag_Rep_Clause (U_Ent); if VM_Target = No_VM then
Set_Has_External_Tag_Rep_Clause (U_Ent);
else
Error_Msg_Name_1 := Attr;
Error_Msg_N
("% attribute unsupported in this configuration", Nam);
end if;
end External_Tag; end External_Tag;
----------- -----------
...@@ -1362,8 +1369,10 @@ package body Sem_Ch13 is ...@@ -1362,8 +1369,10 @@ package body Sem_Ch13 is
-- type Q is access Float; -- type Q is access Float;
-- for Q'Storage_Size use T'Storage_Size; -- incorrect -- for Q'Storage_Size use T'Storage_Size; -- incorrect
if Base_Type (T) = RTE (RE_Stack_Bounded_Pool) then if RTE_Available (RE_Stack_Bounded_Pool)
Error_Msg_N ("non-sharable internal Pool", Expr); and then Base_Type (T) = RTE (RE_Stack_Bounded_Pool)
then
Error_Msg_N ("non-shareable internal Pool", Expr);
return; return;
end if; end if;
...@@ -1502,6 +1511,10 @@ package body Sem_Ch13 is ...@@ -1502,6 +1511,10 @@ package body Sem_Ch13 is
Size : constant Uint := Static_Integer (Expr); Size : constant Uint := Static_Integer (Expr);
begin begin
if Ada_Version <= Ada_95 then
Check_Restriction (No_Implementation_Attributes, N);
end if;
if Has_Stream_Size_Clause (U_Ent) then if Has_Stream_Size_Clause (U_Ent) then
Error_Msg_N ("Stream_Size already given for &", Nam); Error_Msg_N ("Stream_Size already given for &", Nam);
...@@ -2076,6 +2089,9 @@ package body Sem_Ch13 is ...@@ -2076,6 +2089,9 @@ package body Sem_Ch13 is
-- that the back-end can compute and back-annotate properly the -- that the back-end can compute and back-annotate properly the
-- size and alignment of types that may include this record. -- size and alignment of types that may include this record.
-- This seems dubious, this destroys the source tree in a manner
-- not detectable by ASIS ???
if Operating_Mode = Check_Semantics if Operating_Mode = Check_Semantics
and then ASIS_Mode and then ASIS_Mode
then then
...@@ -2116,9 +2132,9 @@ package body Sem_Ch13 is ...@@ -2116,9 +2132,9 @@ package body Sem_Ch13 is
return; return;
end if; end if;
-- If a tag is present, then create a component clause that places -- If a tag is present, then create a component clause that places it
-- it at the start of the record (otherwise gigi may place it after -- at the start of the record (otherwise gigi may place it after other
-- other fields that have rep clauses). -- fields that have rep clauses).
Fent := First_Entity (Rectype); Fent := First_Entity (Rectype);
...@@ -2570,6 +2586,51 @@ package body Sem_Ch13 is ...@@ -2570,6 +2586,51 @@ package body Sem_Ch13 is
Next_Component_Or_Discriminant (Comp); Next_Component_Or_Discriminant (Comp);
end loop; end loop;
-- If no Complete_Representation pragma, warn if missing components
elsif Warn_On_Unrepped_Components
and then not Warnings_Off (Rectype)
then
declare
Num_Repped_Components : Nat := 0;
Num_Unrepped_Components : Nat := 0;
begin
-- First count number of repped and unrepped components
Comp := First_Component_Or_Discriminant (Rectype);
while Present (Comp) loop
if Present (Component_Clause (Comp)) then
Num_Repped_Components := Num_Repped_Components + 1;
else
Num_Unrepped_Components := Num_Unrepped_Components + 1;
end if;
Next_Component_Or_Discriminant (Comp);
end loop;
-- We are only interested in the case where there is at least one
-- unrepped component, and at least half the components have rep
-- clauses. We figure that if less than half have them, then the
-- partial rep clause is really intentional.
if Num_Unrepped_Components > 0
and then Num_Unrepped_Components < Num_Repped_Components
then
Comp := First_Component_Or_Discriminant (Rectype);
while Present (Comp) loop
if No (Component_Clause (Comp)) then
Error_Msg_Sloc := Sloc (Comp);
Error_Msg_NE
("?no component clause given for & declared #",
N, Comp);
end if;
Next_Component_Or_Discriminant (Comp);
end loop;
end if;
end;
end if; end if;
end Analyze_Record_Representation_Clause; end Analyze_Record_Representation_Clause;
...@@ -3472,7 +3533,7 @@ package body Sem_Ch13 is ...@@ -3472,7 +3533,7 @@ package body Sem_Ch13 is
Specification => Build_Spec); Specification => Build_Spec);
-- For a tagged type, there is always a visible declaration for each -- For a tagged type, there is always a visible declaration for each
-- stream TSS (it is a predefined primitive operation), and the for the -- stream TSS (it is a predefined primitive operation), and the
-- completion of this declaration occurs at the freeze point, which is -- completion of this declaration occurs at the freeze point, which is
-- not always visible at places where the attribute definition clause is -- not always visible at places where the attribute definition clause is
-- visible. So, we create a dummy entity here for the purpose of -- visible. So, we create a dummy entity here for the purpose of
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -24,11 +24,12 @@ ...@@ -24,11 +24,12 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Hostparm; with Targparm; use Targparm;
with Namet; use Namet; with Namet; use Namet;
with Opt; use Opt; with Opt; use Opt;
with Osint; use Osint; with Osint; use Osint;
with Output; use Output; with Output; use Output;
with System.WCh_Con; use System.WCh_Con; with System.WCh_Con; use System.WCh_Con;
procedure Usage is procedure Usage is
...@@ -40,6 +41,10 @@ procedure Usage is ...@@ -40,6 +41,10 @@ procedure Usage is
-- than 5 characters, the maximum allowed, Write_Switch_Char will -- than 5 characters, the maximum allowed, Write_Switch_Char will
-- always output exactly 12 characters. -- always output exactly 12 characters.
-----------------------
-- Write_Switch_Char --
-----------------------
procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat") is procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat") is
begin begin
Write_Str (" -"); Write_Str (" -");
...@@ -84,9 +89,9 @@ begin ...@@ -84,9 +89,9 @@ begin
Write_Eol; Write_Eol;
-- Common GCC switches not available in JGNAT -- Common GCC switches not available in JGNAT/MGNAT
if not Hostparm.Java_VM then if VM_Target = No_VM then
Write_Switch_Char ("fstack-check ", ""); Write_Switch_Char ("fstack-check ", "");
Write_Line ("Generate stack checking code"); Write_Line ("Generate stack checking code");
...@@ -361,6 +366,8 @@ begin ...@@ -361,6 +366,8 @@ begin
"(not multiple of small)"); "(not multiple of small)");
Write_Line (" c turn on warnings for constant conditional"); Write_Line (" c turn on warnings for constant conditional");
Write_Line (" C* turn off warnings for constant conditional"); Write_Line (" C* turn off warnings for constant conditional");
Write_Line (" .c turn on warnings for unrepped components");
Write_Line (" .C* turn off warnings for unrepped components");
Write_Line (" d turn on warnings for implicit dereference"); Write_Line (" d turn on warnings for implicit dereference");
Write_Line (" D* turn off warnings for implicit dereference"); Write_Line (" D* turn off warnings for implicit dereference");
Write_Line (" e treat all warnings as errors"); Write_Line (" e treat all warnings as errors");
...@@ -389,14 +396,18 @@ begin ...@@ -389,14 +396,18 @@ begin
Write_Line (" n* normal warning mode (cancels -gnatws/-gnatwe)"); Write_Line (" n* normal warning mode (cancels -gnatws/-gnatwe)");
Write_Line (" o* turn on warnings for address clause overlay"); Write_Line (" o* turn on warnings for address clause overlay");
Write_Line (" O turn off warnings for address clause overlay"); Write_Line (" O turn off warnings for address clause overlay");
Write_Line (" p turn on warnings for ineffective pragma Inline"); Write_Line (" p turn on warnings for ineffective pragma " &
Write_Line (" P* turn off warnings for ineffective pragma Inline"); "Inline in frontend");
Write_Line (" P* turn off warnings for ineffective pragma " &
"Inline in frontend");
Write_Line (" q* turn on warnings for questionable " & Write_Line (" q* turn on warnings for questionable " &
"missing parentheses"); "missing parentheses");
Write_Line (" Q turn off warnings for questionable " & Write_Line (" Q turn off warnings for questionable " &
"missing parentheses"); "missing parentheses");
Write_Line (" r turn on warnings for redundant construct"); Write_Line (" r turn on warnings for redundant construct");
Write_Line (" R* turn off warnings for redundant construct"); Write_Line (" R* turn off warnings for redundant construct");
Write_Line (" .r turn on warnings for object renaming function");
Write_Line (" .R* turn off warnings for object renaming function");
Write_Line (" s suppress all warnings"); Write_Line (" s suppress all warnings");
Write_Line (" t turn on warnings for tracking deleted code"); Write_Line (" t turn on warnings for tracking deleted code");
Write_Line (" T* turn off warnings for tracking deleted code"); Write_Line (" T* turn off warnings for tracking deleted code");
...@@ -460,6 +471,7 @@ begin ...@@ -460,6 +471,7 @@ begin
Write_Line (" d check no DOS line terminators"); Write_Line (" d check no DOS line terminators");
Write_Line (" e check end/exit labels present"); Write_Line (" e check end/exit labels present");
Write_Line (" f check no form feeds/vertical tabs in source"); Write_Line (" f check no form feeds/vertical tabs in source");
Write_Line (" g check standard GNAT style rules");
Write_Line (" h check no horizontal tabs in source"); Write_Line (" h check no horizontal tabs in source");
Write_Line (" i check if-then layout"); Write_Line (" i check if-then layout");
Write_Line (" I check mode in"); Write_Line (" I check mode in");
......
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