Commit 9cb62ce3 by Arnaud Charlet

[multiple changes]

2012-10-04  Robert Dewar  <dewar@adacore.com>

	* sem_res.adb (Resolve_Set_Membership): Warn on duplicates.

2012-10-04  Emmanuel Briot  <briot@adacore.com>

	* g-comlin.adb (Getopt): Fix value of Full_Switch returned in case of
	invalid switch.

2012-10-04  Arnaud Charlet  <charlet@adacore.com>

	* gcc-interface/Make-lang.in: Update dependencies.

From-SVN: r192073
parent 9479ded4
2012-10-04 Robert Dewar <dewar@adacore.com> 2012-10-04 Robert Dewar <dewar@adacore.com>
* sem_res.adb (Resolve_Set_Membership): Warn on duplicates.
2012-10-04 Emmanuel Briot <briot@adacore.com>
* g-comlin.adb (Getopt): Fix value of Full_Switch returned in case of
invalid switch.
2012-10-04 Arnaud Charlet <charlet@adacore.com>
* gcc-interface/Make-lang.in: Update dependencies.
2012-10-04 Robert Dewar <dewar@adacore.com>
* sem_eval.adb (Fold_Str, Fold_Uint, Fold_Ureal): Reset static * sem_eval.adb (Fold_Str, Fold_Uint, Fold_Ureal): Reset static
expression state after Resolve call. expression state after Resolve call.
......
...@@ -7685,10 +7685,11 @@ package body Sem_Res is ...@@ -7685,10 +7685,11 @@ package body Sem_Res is
---------------------------- ----------------------------
procedure Resolve_Set_Membership is procedure Resolve_Set_Membership is
Alt : Node_Id; Alt : Node_Id;
Ltyp : constant Entity_Id := Etype (L);
begin begin
Resolve (L, Etype (L)); Resolve (L, Ltyp);
Alt := First (Alternatives (N)); Alt := First (Alternatives (N));
while Present (Alt) loop while Present (Alt) loop
...@@ -7699,11 +7700,51 @@ package body Sem_Res is ...@@ -7699,11 +7700,51 @@ package body Sem_Res is
if not Is_Entity_Name (Alt) if not Is_Entity_Name (Alt)
or else not Is_Type (Entity (Alt)) or else not Is_Type (Entity (Alt))
then then
Resolve (Alt, Etype (L)); Resolve (Alt, Ltyp);
end if; end if;
Next (Alt); Next (Alt);
end loop; end loop;
-- Check for duplicates for discrete case
if Is_Discrete_Type (Ltyp) then
declare
type Ent is record
Alt : Node_Id;
Val : Uint;
end record;
Alts : array (0 .. List_Length (Alternatives (N))) of Ent;
Nalts : Nat;
begin
-- Loop checking duplicates. This is quadratic, but giant sets
-- are unlikely in this context so it's a reasonable choice.
Nalts := 0;
Alt := First (Alternatives (N));
while Present (Alt) loop
if Is_Static_Expression (Alt)
and then (Nkind_In (Alt, N_Integer_Literal,
N_Character_Literal)
or else Nkind (Alt) in N_Has_Entity)
then
Nalts := Nalts + 1;
Alts (Nalts) := (Alt, Expr_Value (Alt));
for J in 1 .. Nalts - 1 loop
if Alts (J).Val = Alts (Nalts).Val then
Error_Msg_Sloc := Sloc (Alts (J).Alt);
Error_Msg_N ("duplicate of value given#?", Alt);
end if;
end loop;
end if;
Alt := Next (Alt);
end loop;
end;
end if;
end Resolve_Set_Membership; end Resolve_Set_Membership;
-- Start of processing for Resolve_Membership_Op -- Start of processing for Resolve_Membership_Op
......
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