mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-16 23:31:05 +08:00
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
This commit is contained in:
parent
93d15c3331
commit
39a974168f
@ -1,3 +1,9 @@
|
||||
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
|
||||
Case_Node := P_Expression;
|
||||
Set_Name (Variant_Part_Node, Case_Node);
|
||||
|
||||
if Nkind (Case_Node) /= N_Identifier then
|
||||
-- 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;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
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
|
||||
|
8
gcc/testsuite/gnat.dg/specs/variant_part.ads
Normal file
8
gcc/testsuite/gnat.dg/specs/variant_part.ads
Normal file
@ -0,0 +1,8 @@
|
||||
-- { 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;
|
Loading…
x
Reference in New Issue
Block a user