Commit 39a97416 by Samuel Tardieu Committed by Samuel Tardieu

re PR ada/15803 (Illegal program not detected, RM 8.3(19))

    gcc/ada/
	PR ada/15803
	* par-ch3.adb (P_Variant_Part): Signal an error when anything other
	than an identifier is used after "case" in a variant_part.

    gcc/testsuite/
	PR ada/15803
	* gnat.dg/specs/variant_part.ads: New test.

From-SVN: r130495
parent 93d15c33
2007-11-28 Samuel Tardieu <sam@rfc1149.net>
PR ada/15803
* par-ch3.adb (P_Variant_Part): Signal an error when anything other
than an identifier is used after "case" in a variant_part.
2007-11-26 Andreas Krebbel <krebbel1@de.ibm.com>
PR 34081/C++
......@@ -3395,6 +3395,7 @@ package body Ch3 is
Variant_Part_Node : Node_Id;
Variants_List : List_Id;
Case_Node : Node_Id;
Ident_Token : Token_Type;
begin
Variant_Part_Node := New_Node (N_Variant_Part, Token_Ptr);
......@@ -3404,11 +3405,25 @@ package body Ch3 is
Scope.Table (Scope.Last).Ecol := Start_Column;
Scan; -- past CASE
-- A discriminant name between parentheses will be returned as
-- a N_Identifier although it is not allowed by RM 3.8.1. We
-- save the token type to check it later. However, in case of
-- a discriminant name with parentheses, we can continue the
-- analysis as if only the discriminant name had been given.
Ident_Token := Token;
Case_Node := P_Expression;
Set_Name (Variant_Part_Node, Case_Node);
if Nkind (Case_Node) /= N_Identifier then
if Nkind (Case_Node) = N_Identifier then
Set_Name (Variant_Part_Node, Case_Node);
else
Set_Name (Variant_Part_Node, Error);
end if;
if Nkind (Case_Node) /= N_Identifier
or else Ident_Token /= Tok_Identifier
then
Error_Msg ("discriminant name expected", Sloc (Case_Node));
end if;
......
2007-11-28 Samuel Tardieu <sam@rfc1149.net>
PR ada/15803
* gnat.dg/specs/variant_part.ads: New test.
2007-11-28 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/34140
-- { dg-do compile }
package Variant_Part is
type T1(b: boolean) is record
case (b) is -- { dg-error "discriminant name expected" }
when others => null;
end case;
end record;
end Variant_Part;
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