summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/par-ch3.adb19
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gnat.dg/specs/variant_part.ads8
4 files changed, 36 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 9ec417833d6..31f9d19ba51 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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++
diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index b28c93ea5a7..910d16174fe 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b1a58b8667c..fc5de7d497a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gnat.dg/specs/variant_part.ads b/gcc/testsuite/gnat.dg/specs/variant_part.ads
new file mode 100644
index 00000000000..b7ac16ccd42
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/variant_part.ads
@@ -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;
OpenPOWER on IntegriCloud