aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyGHDL/libghdl/vhdl/nodes.py13
-rw-r--r--pyGHDL/libghdl/vhdl/nodes_meta.py121
-rw-r--r--pyGHDL/libghdl/vhdl/tokens.py363
-rw-r--r--src/vhdl/vhdl-nodes.adb16
-rw-r--r--src/vhdl/vhdl-nodes.ads7
-rw-r--r--src/vhdl/vhdl-nodes_meta.adb161
-rw-r--r--src/vhdl/vhdl-nodes_meta.ads2
-rw-r--r--src/vhdl/vhdl-parse.adb24
-rw-r--r--src/vhdl/vhdl-scanner.adb3
-rw-r--r--src/vhdl/vhdl-tokens.adb3
-rw-r--r--src/vhdl/vhdl-tokens.ads1
-rw-r--r--testsuite/gna/issue717/matching_case.vhdl57
-rwxr-xr-xtestsuite/gna/issue717/testsuite.sh11
13 files changed, 465 insertions, 317 deletions
diff --git a/pyGHDL/libghdl/vhdl/nodes.py b/pyGHDL/libghdl/vhdl/nodes.py
index bd26406d2..36cc357e8 100644
--- a/pyGHDL/libghdl/vhdl/nodes.py
+++ b/pyGHDL/libghdl/vhdl/nodes.py
@@ -5920,6 +5920,19 @@ def Set_Case_Statement_Alternative_Chain(obj: Iir, value: Iir) -> None:
@export
+@BindToLibGHDL("vhdl__nodes__get_matching_flag")
+def Get_Matching_Flag(obj: Iir) -> Boolean:
+ """"""
+ return 0
+
+
+@export
+@BindToLibGHDL("vhdl__nodes__set_matching_flag")
+def Set_Matching_Flag(obj: Iir, value: Boolean) -> None:
+ """"""
+
+
+@export
@BindToLibGHDL("vhdl__nodes__get_choice_staticness")
def Get_Choice_Staticness(obj: Iir) -> Iir:
""""""
diff --git a/pyGHDL/libghdl/vhdl/nodes_meta.py b/pyGHDL/libghdl/vhdl/nodes_meta.py
index 848983e87..4e66fae44 100644
--- a/pyGHDL/libghdl/vhdl/nodes_meta.py
+++ b/pyGHDL/libghdl/vhdl/nodes_meta.py
@@ -431,63 +431,64 @@ class fields(IntEnum):
Aggregate_Expand_Flag = 311
Association_Choices_Chain = 312
Case_Statement_Alternative_Chain = 313
- Choice_Staticness = 314
- Procedure_Call = 315
- Implementation = 316
- Parameter_Association_Chain = 317
- Method_Object = 318
- Subtype_Type_Mark = 319
- Subnature_Nature_Mark = 320
- Type_Conversion_Subtype = 321
- Type_Mark = 322
- File_Type_Mark = 323
- Return_Type_Mark = 324
- Has_Disconnect_Flag = 325
- Has_Active_Flag = 326
- Is_Within_Flag = 327
- Type_Marks_List = 328
- Implicit_Alias_Flag = 329
- Alias_Signature = 330
- Attribute_Signature = 331
- Overload_List = 332
- Simple_Name_Identifier = 333
- Simple_Name_Subtype = 334
- Protected_Type_Body = 335
- Protected_Type_Declaration = 336
- Use_Flag = 337
- End_Has_Reserved_Id = 338
- End_Has_Identifier = 339
- End_Has_Postponed = 340
- Has_Label = 341
- Has_Begin = 342
- Has_End = 343
- Has_Is = 344
- Has_Pure = 345
- Has_Body = 346
- Has_Parameter = 347
- Has_Component = 348
- Has_Identifier_List = 349
- Has_Mode = 350
- Has_Class = 351
- Has_Delay_Mechanism = 352
- Suspend_Flag = 353
- Is_Ref = 354
- Is_Forward_Ref = 355
- Psl_Property = 356
- Psl_Sequence = 357
- Psl_Declaration = 358
- Psl_Expression = 359
- Psl_Boolean = 360
- PSL_Clock = 361
- PSL_NFA = 362
- PSL_Nbr_States = 363
- PSL_Clock_Sensitivity = 364
- PSL_EOS_Flag = 365
- PSL_Abort_Flag = 366
- Count_Expression = 367
- Clock_Expression = 368
- Default_Clock = 369
- Foreign_Node = 370
+ Matching_Flag = 314
+ Choice_Staticness = 315
+ Procedure_Call = 316
+ Implementation = 317
+ Parameter_Association_Chain = 318
+ Method_Object = 319
+ Subtype_Type_Mark = 320
+ Subnature_Nature_Mark = 321
+ Type_Conversion_Subtype = 322
+ Type_Mark = 323
+ File_Type_Mark = 324
+ Return_Type_Mark = 325
+ Has_Disconnect_Flag = 326
+ Has_Active_Flag = 327
+ Is_Within_Flag = 328
+ Type_Marks_List = 329
+ Implicit_Alias_Flag = 330
+ Alias_Signature = 331
+ Attribute_Signature = 332
+ Overload_List = 333
+ Simple_Name_Identifier = 334
+ Simple_Name_Subtype = 335
+ Protected_Type_Body = 336
+ Protected_Type_Declaration = 337
+ Use_Flag = 338
+ End_Has_Reserved_Id = 339
+ End_Has_Identifier = 340
+ End_Has_Postponed = 341
+ Has_Label = 342
+ Has_Begin = 343
+ Has_End = 344
+ Has_Is = 345
+ Has_Pure = 346
+ Has_Body = 347
+ Has_Parameter = 348
+ Has_Component = 349
+ Has_Identifier_List = 350
+ Has_Mode = 351
+ Has_Class = 352
+ Has_Delay_Mechanism = 353
+ Suspend_Flag = 354
+ Is_Ref = 355
+ Is_Forward_Ref = 356
+ Psl_Property = 357
+ Psl_Sequence = 358
+ Psl_Declaration = 359
+ Psl_Expression = 360
+ Psl_Boolean = 361
+ PSL_Clock = 362
+ PSL_NFA = 363
+ PSL_Nbr_States = 364
+ PSL_Clock_Sensitivity = 365
+ PSL_EOS_Flag = 366
+ PSL_Abort_Flag = 367
+ Count_Expression = 368
+ Clock_Expression = 369
+ Default_Clock = 370
+ Foreign_Node = 371
def Get_Boolean(node, field):
@@ -2507,6 +2508,12 @@ def Has_Case_Statement_Alternative_Chain(kind: IirKind) -> bool:
@export
+@BindToLibGHDL("vhdl__nodes_meta__has_matching_flag")
+def Has_Matching_Flag(kind: IirKind) -> bool:
+ """"""
+
+
+@export
@BindToLibGHDL("vhdl__nodes_meta__has_choice_staticness")
def Has_Choice_Staticness(kind: IirKind) -> bool:
""""""
diff --git a/pyGHDL/libghdl/vhdl/tokens.py b/pyGHDL/libghdl/vhdl/tokens.py
index 32eb302c8..ed2e9f9dc 100644
--- a/pyGHDL/libghdl/vhdl/tokens.py
+++ b/pyGHDL/libghdl/vhdl/tokens.py
@@ -52,184 +52,185 @@ class Tok(IntEnum):
Plus = 41
Minus = 42
Ampersand = 43
- Condition = 44
- Double_Less = 45
- Double_Greater = 46
- Caret = 47
- And_And = 48
- Bar_Bar = 49
- Left_Curly = 50
- Right_Curly = 51
- Exclam_Mark = 52
- Brack_Star = 53
- Brack_Plus_Brack = 54
- Brack_Arrow = 55
- Brack_Equal = 56
- Bar_Arrow = 57
- Bar_Double_Arrow = 58
- Minus_Greater = 59
- Equiv_Arrow = 60
- Arobase = 61
- Star = 62
- Slash = 63
- Mod = 64
- Rem = 65
- Abs = 66
- Not = 67
- Access = 68
- After = 69
- Alias = 70
- All = 71
- Architecture = 72
- Array = 73
- Assert = 74
- Attribute = 75
- Begin = 76
- Block = 77
- Body = 78
- Buffer = 79
- Bus = 80
- Case = 81
- Component = 82
- Configuration = 83
- Constant = 84
- Disconnect = 85
- Downto = 86
- Else = 87
- Elsif = 88
- End = 89
- Entity = 90
- Exit = 91
- File = 92
- For = 93
- Function = 94
- Generate = 95
- Generic = 96
- Guarded = 97
- If = 98
- In = 99
- Inout = 100
- Is = 101
- Label = 102
- Library = 103
- Linkage = 104
- Loop = 105
- Map = 106
- New = 107
- Next = 108
- Null = 109
- Of = 110
- On = 111
- Open = 112
- Others = 113
- Out = 114
- Package = 115
- Port = 116
- Procedure = 117
- Process = 118
- Range = 119
- Record = 120
- Register = 121
- Report = 122
- Return = 123
- Select = 124
- Severity = 125
- Signal = 126
- Subtype = 127
- Then = 128
- To = 129
- Transport = 130
- Type = 131
- Units = 132
- Until = 133
- Use = 134
- Variable = 135
- Wait = 136
- When = 137
- While = 138
- With = 139
- And = 140
- Or = 141
- Xor = 142
- Nand = 143
- Nor = 144
- Xnor = 145
- Group = 146
- Impure = 147
- Inertial = 148
- Literal = 149
- Postponed = 150
- Pure = 151
- Reject = 152
- Shared = 153
- Unaffected = 154
- Sll = 155
- Sla = 156
- Sra = 157
- Srl = 158
- Rol = 159
- Ror = 160
- Protected = 161
- Assume = 162
- Context = 163
- Cover = 164
- Default = 165
- Force = 166
- Parameter = 167
- Property = 168
- Release = 169
- Restrict = 170
- Restrict_Guarantee = 171
- Sequence = 172
- Vmode = 173
- Vprop = 174
- Vunit = 175
- Across = 176
- Break = 177
- Limit = 178
- Nature = 179
- Noise = 180
- Procedural = 181
- Quantity = 182
- Reference = 183
- Spectrum = 184
- Subnature = 185
- Terminal = 186
- Through = 187
- Tolerance = 188
- Psl_Clock = 189
- Psl_Endpoint = 190
- Psl_Const = 191
- Psl_Boolean = 192
- Inf = 193
- Within = 194
- Abort = 195
- Async_Abort = 196
- Sync_Abort = 197
- Before = 198
- Before_Em = 199
- Before_Un = 200
- Before_Em_Un = 201
- Always = 202
- Never = 203
- Eventually_Em = 204
- Next_Em = 205
- Next_A = 206
- Next_A_Em = 207
- Next_E = 208
- Next_E_Em = 209
- Next_Event = 210
- Next_Event_Em = 211
- Next_Event_A = 212
- Next_Event_A_Em = 213
- Next_Event_E = 214
- Next_Event_E_Em = 215
- Until_Em = 216
- Until_Un = 217
- Until_Em_Un = 218
- Prev = 219
- Stable = 220
- Fell = 221
- Rose = 222
- Onehot = 223
- Onehot0 = 224
+ Question_Mark = 44
+ Condition = 45
+ Double_Less = 46
+ Double_Greater = 47
+ Caret = 48
+ And_And = 49
+ Bar_Bar = 50
+ Left_Curly = 51
+ Right_Curly = 52
+ Exclam_Mark = 53
+ Brack_Star = 54
+ Brack_Plus_Brack = 55
+ Brack_Arrow = 56
+ Brack_Equal = 57
+ Bar_Arrow = 58
+ Bar_Double_Arrow = 59
+ Minus_Greater = 60
+ Equiv_Arrow = 61
+ Arobase = 62
+ Star = 63
+ Slash = 64
+ Mod = 65
+ Rem = 66
+ Abs = 67
+ Not = 68
+ Access = 69
+ After = 70
+ Alias = 71
+ All = 72
+ Architecture = 73
+ Array = 74
+ Assert = 75
+ Attribute = 76
+ Begin = 77
+ Block = 78
+ Body = 79
+ Buffer = 80
+ Bus = 81
+ Case = 82
+ Component = 83
+ Configuration = 84
+ Constant = 85
+ Disconnect = 86
+ Downto = 87
+ Else = 88
+ Elsif = 89
+ End = 90
+ Entity = 91
+ Exit = 92
+ File = 93
+ For = 94
+ Function = 95
+ Generate = 96
+ Generic = 97
+ Guarded = 98
+ If = 99
+ In = 100
+ Inout = 101
+ Is = 102
+ Label = 103
+ Library = 104
+ Linkage = 105
+ Loop = 106
+ Map = 107
+ New = 108
+ Next = 109
+ Null = 110
+ Of = 111
+ On = 112
+ Open = 113
+ Others = 114
+ Out = 115
+ Package = 116
+ Port = 117
+ Procedure = 118
+ Process = 119
+ Range = 120
+ Record = 121
+ Register = 122
+ Report = 123
+ Return = 124
+ Select = 125
+ Severity = 126
+ Signal = 127
+ Subtype = 128
+ Then = 129
+ To = 130
+ Transport = 131
+ Type = 132
+ Units = 133
+ Until = 134
+ Use = 135
+ Variable = 136
+ Wait = 137
+ When = 138
+ While = 139
+ With = 140
+ And = 141
+ Or = 142
+ Xor = 143
+ Nand = 144
+ Nor = 145
+ Xnor = 146
+ Group = 147
+ Impure = 148
+ Inertial = 149
+ Literal = 150
+ Postponed = 151
+ Pure = 152
+ Reject = 153
+ Shared = 154
+ Unaffected = 155
+ Sll = 156
+ Sla = 157
+ Sra = 158
+ Srl = 159
+ Rol = 160
+ Ror = 161
+ Protected = 162
+ Assume = 163
+ Context = 164
+ Cover = 165
+ Default = 166
+ Force = 167
+ Parameter = 168
+ Property = 169
+ Release = 170
+ Restrict = 171
+ Restrict_Guarantee = 172
+ Sequence = 173
+ Vmode = 174
+ Vprop = 175
+ Vunit = 176
+ Across = 177
+ Break = 178
+ Limit = 179
+ Nature = 180
+ Noise = 181
+ Procedural = 182
+ Quantity = 183
+ Reference = 184
+ Spectrum = 185
+ Subnature = 186
+ Terminal = 187
+ Through = 188
+ Tolerance = 189
+ Psl_Clock = 190
+ Psl_Endpoint = 191
+ Psl_Const = 192
+ Psl_Boolean = 193
+ Inf = 194
+ Within = 195
+ Abort = 196
+ Async_Abort = 197
+ Sync_Abort = 198
+ Before = 199
+ Before_Em = 200
+ Before_Un = 201
+ Before_Em_Un = 202
+ Always = 203
+ Never = 204
+ Eventually_Em = 205
+ Next_Em = 206
+ Next_A = 207
+ Next_A_Em = 208
+ Next_E = 209
+ Next_E_Em = 210
+ Next_Event = 211
+ Next_Event_Em = 212
+ Next_Event_A = 213
+ Next_Event_A_Em = 214
+ Next_Event_E = 215
+ Next_Event_E_Em = 216
+ Until_Em = 217
+ Until_Un = 218
+ Until_Em_Un = 219
+ Prev = 220
+ Stable = 221
+ Fell = 222
+ Rose = 223
+ Onehot = 224
+ Onehot0 = 225
diff --git a/src/vhdl/vhdl-nodes.adb b/src/vhdl/vhdl-nodes.adb
index 1912fcb12..def8a9695 100644
--- a/src/vhdl/vhdl-nodes.adb
+++ b/src/vhdl/vhdl-nodes.adb
@@ -6461,6 +6461,22 @@ package body Vhdl.Nodes is
Set_Field1 (Target, Chain);
end Set_Case_Statement_Alternative_Chain;
+ function Get_Matching_Flag (Target : Iir) return Boolean is
+ begin
+ pragma Assert (Target /= Null_Iir);
+ pragma Assert (Has_Matching_Flag (Get_Kind (Target)),
+ "no field Matching_Flag");
+ return Get_Flag1 (Target);
+ end Get_Matching_Flag;
+
+ procedure Set_Matching_Flag (Target : Iir; Flag : Boolean) is
+ begin
+ pragma Assert (Target /= Null_Iir);
+ pragma Assert (Has_Matching_Flag (Get_Kind (Target)),
+ "no field Matching_Flag");
+ Set_Flag1 (Target, Flag);
+ end Set_Matching_Flag;
+
function Get_Choice_Staticness (Target : Iir) return Iir_Staticness is
begin
pragma Assert (Target /= Null_Iir);
diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads
index 741ddb56f..8d123e3a3 100644
--- a/src/vhdl/vhdl-nodes.ads
+++ b/src/vhdl/vhdl-nodes.ads
@@ -4016,6 +4016,8 @@ package Vhdl.Nodes is
--
-- Get/Set_Expression (Field5)
--
+ -- Get/Set_Matching_Flag (Flag1)
+ --
-- Chain is composed of Iir_Kind_Choice_By_XXX.
-- Get/Set_Case_Statement_Alternative_Chain (Field1)
--
@@ -9002,6 +9004,11 @@ package Vhdl.Nodes is
function Get_Case_Statement_Alternative_Chain (Target : Iir) return Iir;
procedure Set_Case_Statement_Alternative_Chain (Target : Iir; Chain : Iir);
+ -- Matching condition for case statement.
+ -- Field: Flag1
+ function Get_Matching_Flag (Target : Iir) return Boolean;
+ procedure Set_Matching_Flag (Target : Iir; Flag : Boolean);
+
-- Staticness of the choice.
-- Field: State1 (pos)
function Get_Choice_Staticness (Target : Iir) return Iir_Staticness;
diff --git a/src/vhdl/vhdl-nodes_meta.adb b/src/vhdl/vhdl-nodes_meta.adb
index 2981b9f5c..44dc8a566 100644
--- a/src/vhdl/vhdl-nodes_meta.adb
+++ b/src/vhdl/vhdl-nodes_meta.adb
@@ -331,6 +331,7 @@ package body Vhdl.Nodes_Meta is
Field_Aggregate_Expand_Flag => Type_Boolean,
Field_Association_Choices_Chain => Type_Iir,
Field_Case_Statement_Alternative_Chain => Type_Iir,
+ Field_Matching_Flag => Type_Boolean,
Field_Choice_Staticness => Type_Iir_Staticness,
Field_Procedure_Call => Type_Iir,
Field_Implementation => Type_Iir,
@@ -1026,6 +1027,8 @@ package body Vhdl.Nodes_Meta is
return "association_choices_chain";
when Field_Case_Statement_Alternative_Chain =>
return "case_statement_alternative_chain";
+ when Field_Matching_Flag =>
+ return "matching_flag";
when Field_Choice_Staticness =>
return "choice_staticness";
when Field_Procedure_Call =>
@@ -2416,6 +2419,8 @@ package body Vhdl.Nodes_Meta is
return Attr_Chain;
when Field_Case_Statement_Alternative_Chain =>
return Attr_Chain;
+ when Field_Matching_Flag =>
+ return Attr_None;
when Field_Choice_Staticness =>
return Attr_None;
when Field_Procedure_Call =>
@@ -4721,6 +4726,7 @@ package body Vhdl.Nodes_Meta is
Field_Loop_Label,
-- Iir_Kind_Case_Statement
Field_Label,
+ Field_Matching_Flag,
Field_Suspend_Flag,
Field_Visible_Flag,
Field_End_Has_Identifier,
@@ -5485,79 +5491,79 @@ package body Vhdl.Nodes_Meta is
Iir_Kind_While_Loop_Statement => 1924,
Iir_Kind_Next_Statement => 1931,
Iir_Kind_Exit_Statement => 1938,
- Iir_Kind_Case_Statement => 1946,
- Iir_Kind_Procedure_Call_Statement => 1952,
- Iir_Kind_Break_Statement => 1959,
- Iir_Kind_If_Statement => 1969,
- Iir_Kind_Elsif => 1975,
- Iir_Kind_Character_Literal => 1982,
- Iir_Kind_Simple_Name => 1989,
- Iir_Kind_Selected_Name => 1997,
- Iir_Kind_Operator_Symbol => 2002,
- Iir_Kind_Reference_Name => 2007,
- Iir_Kind_External_Constant_Name => 2016,
- Iir_Kind_External_Signal_Name => 2025,
- Iir_Kind_External_Variable_Name => 2035,
- Iir_Kind_Selected_By_All_Name => 2041,
- Iir_Kind_Parenthesis_Name => 2046,
- Iir_Kind_Package_Pathname => 2050,
- Iir_Kind_Absolute_Pathname => 2051,
- Iir_Kind_Relative_Pathname => 2052,
- Iir_Kind_Pathname_Element => 2057,
- Iir_Kind_Base_Attribute => 2059,
- Iir_Kind_Subtype_Attribute => 2064,
- Iir_Kind_Element_Attribute => 2069,
- Iir_Kind_Across_Attribute => 2074,
- Iir_Kind_Through_Attribute => 2079,
- Iir_Kind_Nature_Reference_Attribute => 2083,
- Iir_Kind_Left_Type_Attribute => 2088,
- Iir_Kind_Right_Type_Attribute => 2093,
- Iir_Kind_High_Type_Attribute => 2098,
- Iir_Kind_Low_Type_Attribute => 2103,
- Iir_Kind_Ascending_Type_Attribute => 2108,
- Iir_Kind_Image_Attribute => 2114,
- Iir_Kind_Value_Attribute => 2120,
- Iir_Kind_Pos_Attribute => 2126,
- Iir_Kind_Val_Attribute => 2132,
- Iir_Kind_Succ_Attribute => 2138,
- Iir_Kind_Pred_Attribute => 2144,
- Iir_Kind_Leftof_Attribute => 2150,
- Iir_Kind_Rightof_Attribute => 2156,
- Iir_Kind_Signal_Slew_Attribute => 2164,
- Iir_Kind_Quantity_Slew_Attribute => 2172,
- Iir_Kind_Ramp_Attribute => 2180,
- Iir_Kind_Zoh_Attribute => 2188,
- Iir_Kind_Ltf_Attribute => 2196,
- Iir_Kind_Ztf_Attribute => 2206,
- Iir_Kind_Dot_Attribute => 2213,
- Iir_Kind_Integ_Attribute => 2220,
- Iir_Kind_Above_Attribute => 2228,
- Iir_Kind_Quantity_Delayed_Attribute => 2236,
- Iir_Kind_Delayed_Attribute => 2245,
- Iir_Kind_Stable_Attribute => 2254,
- Iir_Kind_Quiet_Attribute => 2263,
- Iir_Kind_Transaction_Attribute => 2272,
- Iir_Kind_Event_Attribute => 2276,
- Iir_Kind_Active_Attribute => 2280,
- Iir_Kind_Last_Event_Attribute => 2284,
- Iir_Kind_Last_Active_Attribute => 2288,
- Iir_Kind_Last_Value_Attribute => 2292,
- Iir_Kind_Driving_Attribute => 2296,
- Iir_Kind_Driving_Value_Attribute => 2300,
- Iir_Kind_Behavior_Attribute => 2300,
- Iir_Kind_Structure_Attribute => 2300,
- Iir_Kind_Simple_Name_Attribute => 2307,
- Iir_Kind_Instance_Name_Attribute => 2312,
- Iir_Kind_Path_Name_Attribute => 2317,
- Iir_Kind_Left_Array_Attribute => 2324,
- Iir_Kind_Right_Array_Attribute => 2331,
- Iir_Kind_High_Array_Attribute => 2338,
- Iir_Kind_Low_Array_Attribute => 2345,
- Iir_Kind_Length_Array_Attribute => 2352,
- Iir_Kind_Ascending_Array_Attribute => 2359,
- Iir_Kind_Range_Array_Attribute => 2366,
- Iir_Kind_Reverse_Range_Array_Attribute => 2373,
- Iir_Kind_Attribute_Name => 2382
+ Iir_Kind_Case_Statement => 1947,
+ Iir_Kind_Procedure_Call_Statement => 1953,
+ Iir_Kind_Break_Statement => 1960,
+ Iir_Kind_If_Statement => 1970,
+ Iir_Kind_Elsif => 1976,
+ Iir_Kind_Character_Literal => 1983,
+ Iir_Kind_Simple_Name => 1990,
+ Iir_Kind_Selected_Name => 1998,
+ Iir_Kind_Operator_Symbol => 2003,
+ Iir_Kind_Reference_Name => 2008,
+ Iir_Kind_External_Constant_Name => 2017,
+ Iir_Kind_External_Signal_Name => 2026,
+ Iir_Kind_External_Variable_Name => 2036,
+ Iir_Kind_Selected_By_All_Name => 2042,
+ Iir_Kind_Parenthesis_Name => 2047,
+ Iir_Kind_Package_Pathname => 2051,
+ Iir_Kind_Absolute_Pathname => 2052,
+ Iir_Kind_Relative_Pathname => 2053,
+ Iir_Kind_Pathname_Element => 2058,
+ Iir_Kind_Base_Attribute => 2060,
+ Iir_Kind_Subtype_Attribute => 2065,
+ Iir_Kind_Element_Attribute => 2070,
+ Iir_Kind_Across_Attribute => 2075,
+ Iir_Kind_Through_Attribute => 2080,
+ Iir_Kind_Nature_Reference_Attribute => 2084,
+ Iir_Kind_Left_Type_Attribute => 2089,
+ Iir_Kind_Right_Type_Attribute => 2094,
+ Iir_Kind_High_Type_Attribute => 2099,
+ Iir_Kind_Low_Type_Attribute => 2104,
+ Iir_Kind_Ascending_Type_Attribute => 2109,
+ Iir_Kind_Image_Attribute => 2115,
+ Iir_Kind_Value_Attribute => 2121,
+ Iir_Kind_Pos_Attribute => 2127,
+ Iir_Kind_Val_Attribute => 2133,
+ Iir_Kind_Succ_Attribute => 2139,
+ Iir_Kind_Pred_Attribute => 2145,
+ Iir_Kind_Leftof_Attribute => 2151,
+ Iir_Kind_Rightof_Attribute => 2157,
+ Iir_Kind_Signal_Slew_Attribute => 2165,
+ Iir_Kind_Quantity_Slew_Attribute => 2173,
+ Iir_Kind_Ramp_Attribute => 2181,
+ Iir_Kind_Zoh_Attribute => 2189,
+ Iir_Kind_Ltf_Attribute => 2197,
+ Iir_Kind_Ztf_Attribute => 2207,
+ Iir_Kind_Dot_Attribute => 2214,
+ Iir_Kind_Integ_Attribute => 2221,
+ Iir_Kind_Above_Attribute => 2229,
+ Iir_Kind_Quantity_Delayed_Attribute => 2237,
+ Iir_Kind_Delayed_Attribute => 2246,
+ Iir_Kind_Stable_Attribute => 2255,
+ Iir_Kind_Quiet_Attribute => 2264,
+ Iir_Kind_Transaction_Attribute => 2273,
+ Iir_Kind_Event_Attribute => 2277,
+ Iir_Kind_Active_Attribute => 2281,
+ Iir_Kind_Last_Event_Attribute => 2285,
+ Iir_Kind_Last_Active_Attribute => 2289,
+ Iir_Kind_Last_Value_Attribute => 2293,
+ Iir_Kind_Driving_Attribute => 2297,
+ Iir_Kind_Driving_Value_Attribute => 2301,
+ Iir_Kind_Behavior_Attribute => 2301,
+ Iir_Kind_Structure_Attribute => 2301,
+ Iir_Kind_Simple_Name_Attribute => 2308,
+ Iir_Kind_Instance_Name_Attribute => 2313,
+ Iir_Kind_Path_Name_Attribute => 2318,
+ Iir_Kind_Left_Array_Attribute => 2325,
+ Iir_Kind_Right_Array_Attribute => 2332,
+ Iir_Kind_High_Array_Attribute => 2339,
+ Iir_Kind_Low_Array_Attribute => 2346,
+ Iir_Kind_Length_Array_Attribute => 2353,
+ Iir_Kind_Ascending_Array_Attribute => 2360,
+ Iir_Kind_Range_Array_Attribute => 2367,
+ Iir_Kind_Reverse_Range_Array_Attribute => 2374,
+ Iir_Kind_Attribute_Name => 2383
);
function Get_Fields_First (K : Iir_Kind) return Fields_Index is
@@ -5684,6 +5690,8 @@ package body Vhdl.Nodes_Meta is
return Get_Aggr_Named_Flag (N);
when Field_Aggregate_Expand_Flag =>
return Get_Aggregate_Expand_Flag (N);
+ when Field_Matching_Flag =>
+ return Get_Matching_Flag (N);
when Field_Has_Disconnect_Flag =>
return Get_Has_Disconnect_Flag (N);
when Field_Has_Active_Flag =>
@@ -5836,6 +5844,8 @@ package body Vhdl.Nodes_Meta is
Set_Aggr_Named_Flag (N, V);
when Field_Aggregate_Expand_Flag =>
Set_Aggregate_Expand_Flag (N, V);
+ when Field_Matching_Flag =>
+ Set_Matching_Flag (N, V);
when Field_Has_Disconnect_Flag =>
Set_Has_Disconnect_Flag (N, V);
when Field_Has_Active_Flag =>
@@ -11891,6 +11901,11 @@ package body Vhdl.Nodes_Meta is
end case;
end Has_Case_Statement_Alternative_Chain;
+ function Has_Matching_Flag (K : Iir_Kind) return Boolean is
+ begin
+ return K = Iir_Kind_Case_Statement;
+ end Has_Matching_Flag;
+
function Has_Choice_Staticness (K : Iir_Kind) return Boolean is
begin
case K is
diff --git a/src/vhdl/vhdl-nodes_meta.ads b/src/vhdl/vhdl-nodes_meta.ads
index 540807d1b..f72a697e3 100644
--- a/src/vhdl/vhdl-nodes_meta.ads
+++ b/src/vhdl/vhdl-nodes_meta.ads
@@ -375,6 +375,7 @@ package Vhdl.Nodes_Meta is
Field_Aggregate_Expand_Flag,
Field_Association_Choices_Chain,
Field_Case_Statement_Alternative_Chain,
+ Field_Matching_Flag,
Field_Choice_Staticness,
Field_Procedure_Call,
Field_Implementation,
@@ -965,6 +966,7 @@ package Vhdl.Nodes_Meta is
function Has_Association_Choices_Chain (K : Iir_Kind) return Boolean;
function Has_Case_Statement_Alternative_Chain (K : Iir_Kind)
return Boolean;
+ function Has_Matching_Flag (K : Iir_Kind) return Boolean;
function Has_Choice_Staticness (K : Iir_Kind) return Boolean;
function Has_Procedure_Call (K : Iir_Kind) return Boolean;
function Has_Implementation (K : Iir_Kind) return Boolean;
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb
index 0dbb227e9..7605da5f8 100644
--- a/src/vhdl/vhdl-parse.adb
+++ b/src/vhdl/vhdl-parse.adb
@@ -7624,15 +7624,15 @@ package body Vhdl.Parse is
-- precond: CASE
-- postcond: ';'
--
- -- [ LRM93 8.8 ]
+ -- [ LRM08 10.9 ]
-- case_statement ::=
-- [ CASE_label : ]
- -- CASE expression IS
+ -- CASE [?] expression IS
-- case_statement_alternative
-- { case_statement_alternative }
- -- END CASE [ CASE_label ] ;
+ -- END CASE [?] [ CASE_label ] ;
--
- -- [ LRM93 8.8 ]
+ -- [ LRM08 10.9]
-- case_statement_alternative ::= WHEN choices => sequence_of_statements
function Parse_Case_Statement (Label : Name_Id) return Iir
is
@@ -7648,6 +7648,17 @@ package body Vhdl.Parse is
-- Skip 'case'.
Scan;
+ if Flags.Vhdl_Std >= Vhdl_08 then
+ -- Check ? for matching case
+ if Current_Token = Tok_Question_Mark then
+ -- Skip ?
+ Scan;
+ -- Mark the case as matching case statement
+ Set_Matching_Flag (Stmt, True);
+ end if;
+ end if;
+
+ -- Parse the Expression
Set_Expression (Stmt, Parse_Case_Expression);
-- Skip 'is'.
@@ -7683,6 +7694,11 @@ package body Vhdl.Parse is
Expect_Scan (Tok_End);
Expect_Scan (Tok_Case);
+ if Get_Matching_Flag (Stmt) then
+ -- Matching case statement must match the ?
+ Expect_Scan (Tok_Question_Mark);
+ end if ;
+
if Flags.Vhdl_Std >= Vhdl_93 then
Check_End_Name (Stmt);
end if;
diff --git a/src/vhdl/vhdl-scanner.adb b/src/vhdl/vhdl-scanner.adb
index 76e6fe5fd..10181cd6c 100644
--- a/src/vhdl/vhdl-scanner.adb
+++ b/src/vhdl/vhdl-scanner.adb
@@ -2559,9 +2559,8 @@ package body Vhdl.Scanner is
Current_Token := Tok_Match_Not_Equal;
Pos := Pos + 3;
else
- Error_Msg_Scan ("unknown matching operator");
+ Current_Token := Tok_Question_Mark;
Pos := Pos + 1;
- goto Again;
end if;
end if;
return;
diff --git a/src/vhdl/vhdl-tokens.adb b/src/vhdl/vhdl-tokens.adb
index 815f0aba2..b8838c1db 100644
--- a/src/vhdl/vhdl-tokens.adb
+++ b/src/vhdl/vhdl-tokens.adb
@@ -116,6 +116,9 @@ package body Vhdl.Tokens is
when Tok_Ampersand =>
return "&";
+ when Tok_Question_Mark =>
+ return "?";
+
when Tok_Condition =>
return "??";
diff --git a/src/vhdl/vhdl-tokens.ads b/src/vhdl/vhdl-tokens.ads
index 4e6d3a2e2..5caba9dd9 100644
--- a/src/vhdl/vhdl-tokens.ads
+++ b/src/vhdl/vhdl-tokens.ads
@@ -85,6 +85,7 @@ package Vhdl.Tokens is
Tok_Ampersand, -- &
-- VHDL 2008
+ Tok_Question_Mark, -- ?
Tok_Condition, -- ??
Tok_Double_Less, -- <<
Tok_Double_Greater, -- >>
diff --git a/testsuite/gna/issue717/matching_case.vhdl b/testsuite/gna/issue717/matching_case.vhdl
new file mode 100644
index 000000000..80e059528
--- /dev/null
+++ b/testsuite/gna/issue717/matching_case.vhdl
@@ -0,0 +1,57 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity CounterWithReset is
+ generic (gWidth : natural := 16);
+ port(
+ iClk : in std_ulogic;
+ inRstAsync : in std_ulogic;
+ iCtrl : in std_ulogic_vector (2 downto 0);
+ oData : out unsigned(gWidth-1 downto 0)
+ );
+end entity CounterWithReset;
+
+architecture RTL of CounterWithReset is
+ signal CountStateM, CountStateNextM : unsigned(oData'RANGE);
+ signal CountState, CountStateNext : unsigned(oData'RANGE);
+ signal Ctrl : std_ulogic_vector(iCtrl'RANGE);
+ signal a, b : std_ulogic ;
+begin
+ count : process (iClk, inRstAsync) is
+ begin
+ if inRstAsync = '0' then
+ CountState <= (others=>'0');
+ Ctrl <= (others => '0');
+ elsif rising_edge(iClk) then
+ CountState <= CountStateNext;
+ Ctrl <= iCtrl;
+ end if;
+ end process;
+
+ counter : process(Ctrl, CountState) is
+ begin
+ CountStateNext <= CountState;
+ --our counter has 3 control bits
+ --the first(left) bit is enable
+ --the other two bits control the mode
+ case ?(ctrl) is
+ when "0--" => --enable bit is not set. we don't count
+ when "100" => CountStateNextM <= CountStateM + 1; --count up
+ when "101" => CountStateNextM <= CountStateM + 2; --count up 2
+ when "110" => CountStateNextM <= CountStateM - 1; --count down
+ when "111" => CountStateNextM <= CountStateM - 2; --count down 2
+ when others => CountStateNextM <= (others=>'X');
+ end case?;
+ case ctrl is
+ when "0--" => --enable bit is not set. we don't count
+ when "100" => CountStateNext <= CountState + 1; --count up
+ when "101" => CountStateNext <= CountState + 2; --count up 2
+ when "110" => CountStateNext <= CountState - 1; --count down
+ when "111" => CountStateNext <= CountState - 2; --count down 2
+ when others => CountStateNext <= (others=>'X');
+ end case;
+ end process;
+
+ oData <= CountState;
+end architecture RTL;
diff --git a/testsuite/gna/issue717/testsuite.sh b/testsuite/gna/issue717/testsuite.sh
new file mode 100755
index 000000000..c3bac1dd8
--- /dev/null
+++ b/testsuite/gna/issue717/testsuite.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+
+analyze matching_case.vhdl
+
+clean
+
+echo "Test successful"