This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Tested on i686-linux, committed on trunk.
This patch extends the applicability of pragma Obsolescent to all
entities, including record components and enumeration literals. Any
reference to an obsolete component will generate a warning.
Given the following sources:
package p is
pragma Obsolescent ("obsolescent package, old syntax");
end p;
package q is
procedure qp;
pragma Obsolescent ("obsolescent procedure, old syntax");
procedure q2;
pragma Obsolescent (Entity => q2, "obsolescent procedure, new syntax");
type R is new integer;
pragma Obsolescent (Entity => R, "obsolescent type");
type M is record
F1 : Integer;
F2 : Integer;
pragma Obsolescent (Entity => F2, "obsolescent component");
F3 : Integer;
end record;
type E is (a, bc, 'd', quack);
pragma Obsolescent (Entity => bc, "obsolescent enumeration identifier");
pragma Obsolescent (Entity => 'd', "obsolescent enumeration char lit");
function "+" (a, b : character) return character;
pragma Obsolescent (Entity => "+");
end;
with p;
with q; use q;
procedure main is
x : integer;
oi : r := 3;
mm : m;
ee : e;
c : character := 'x';
begin
mm := (1, 2, 3);
qp;
q2;
oi := oi + 1;
x := mm.f1;
x := mm.f2;
ee := a;
ee := bc;
ee := 'd';
c := "+" (c, c);
c := c + c;
end;
Compiling main.adb with switches -gnatwj -gnatj60 -gnatld7 gives:
1. with p;
|
>>> warning: with of obsolescent package "p"
declared at p.ads:1
obsolescent package, old syntax
2. with q; use q;
3. procedure main is
4. x : integer;
5. oi : r := 3;
|
>>> warning: reference to obsolescent type "R"
declared at q.ads:8
obsolescent type
6. mm : m;
7. ee : e;
8. c : character := 'x';
9. begin
10. mm := (1, 2, 3);
11. qp;
|
>>> warning: call to obsolescent procedure "qp"
declared at q.ads:2
obsolescent procedure, old syntax
12. q2;
|
>>> warning: call to obsolescent procedure "q2"
declared at q.ads:5
obsolescent procedure, new syntax
13. oi := oi + 1;
14. x := mm.f1;
15. x := mm.f2;
|
>>> warning: reference to obsolescent component
"F2" declared at q.ads:13
obsolescent component
16. ee := a;
17. ee := bc;
|
>>> warning: reference to obsolescent enumeration
literal "bc" declared at q.ads:18
obsolescent enumeration identifier
18. ee := 'd';
|
>>> warning: reference to obsolescent enumeration
literal "'d'" declared at q.ads:18
obsolescent enumeration char lit
19. c := "+" (c, c);
|
>>> warning: call to obsolescent function "+"
declared at q.ads:22
20. c := c + c;
|
>>> warning: call to obsolescent function "+"
declared at q.ads:22
21. end;
21 lines: No errors, 9 warnings
This patch also enhances pragma Interface so that it is now exactly the
same as pragma Import syntactically (except for the name) and also
semantically. This is an upwards compatible change. The new version
is still upwards compatible with the Ada 83 version of Interface,
and also upwards compatible with some Ada 83 extended versions of
this pragma that allowed more than two arguments.
The following program now compiles and runs, printing hello:
void puthello () {printf ("hello\n");}
procedure k is
procedure Puth;
pragma Interface (C, Puth, "puthello");
begin
Puth;
end;
Finally, this patch corrects a problem with the Compile_Time_Warning pragma.
The string was being sent directly to Error_Msg_N, causing blowups
when it contained insertion characters. The circuit is rewritten
to use the new ~ string insertion feature to eliminate this
problem.
The following program:
procedure P is begin null; end;
pragma Compile_Time_Warning
(True, "bogus insertion %" & ASCII.LF & "ok");
used to blow up. With this patch, it outputs the expected:
p.adb:3:04: warning: bogus insertion %
p.adb:3:04: warning: ok
previously blew up
2006-10-31 Robert Dewar <dewar@adacore.com>
* exp_prag.adb (Expand_Pragma_Common_Object): Use a single
Machine_Attribute pragma internally to implement the user pragma.
Add processing for pragma Interface so that it is now completely
equivalent to pragma Import.
* sem_prag.adb (Analyze_Pragma, case Obsolescent): Extend this pragma
so that it can be applied to all entities, including record components
and enumeration literals.
(Analyze_Pragma, case Priority_Specific_Dispatching): Check whether
priority ranges are correct, verify compatibility against task
dispatching and locking policies, and if everything is correct an entry
is added to the table containing priority specific dispatching entries
for this compilation unit.
(Delay_Config_Pragma_Analyze): Delay processing
Priority_Specific_Dispatching pragmas because when processing the
pragma we need to access run-time data, such as the range of
System.Any_Priority.
(Sig_Flags): Add Pragma_Priority_Specific_Dispatching.
Allow pragma Unreferenced as a context item
Add pragma Preelaborable_Initialization
(Analyze_Pragma, case Interface): Interface is extended so that it is
now syntactically and semantically equivalent to Import.
(Analyze_Pragma, case Compile_Time_Warning): Fix error of blowups on
insertion characters.
Add handling for Pragma_Wide_Character_Encoding
(Process_Restrictions_Restriction_Warnings): Ensure that a warning
never supercedes a real restriction, and that a real restriction
always supercedes a warning.
(Analyze_Pragma, case Assert): Set Low_Bound_Known if assert is of
appropriate form.
Attachment:
difs
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |