VHDL Issue Number: 0194 Classification: Language Definition Problem Language Version: VHDL-87 Summary: VPI Issue 18 -- Use of element names within records Related Issues: TBD Relevant LRM Sections: 3.2.2 Key Words and Phrases: name, record, element. Current Status: ISAC-Approved 1076-1993 Disposition: Closed (All Issues Completely Addressed) Disposition Rationale: Chapter 0 clarifies terminology in the LRM. Superseded By: N/A ----------------------- Date Submitted: 1991/03/15 Author of Submission: J. R. Armstrong Author's Affiliation: Virginia Polytechnic Institute and State University Author's Post Address: Bradley Department of Electrical Engineering Virginia Polytechnic Institute and State University Blacksburg, VA 24061 Author's Phone Number: (703) 231-4723 Author's Fax Number: Author's Net Address: JRA@VTVM1.CC.VT.EDU ----------------------- Date Analyzed: 1991/11/21 Author of Analysis: Oz Levia Revision Number: $Revision: 1.10 $ Date Last Revised: $Date: 1995/05/13 19:34:42 $ Description of Problem ---------------------- Is it allowed to use an element name defined in a record type definition elsewhere within the record type de- finition? Test File: ch03/s02/s2/02030101.vhd LRM section 3.2.2, paragraph 2 specifies that: Each element declaration declares an element of a record type. The identifiers of all elements of a record type must be distinct. THE USE OF A NAME THAT DENOTES A RECORD ELE- MENT IS NOT ALLOWED WITHIN THE RECORD TYPE DEFINITION THAT DECLARES THE ELEMENT. The last sentence could be interpreted as the following two ways: 1. The use of a name that denotes a record element is not allowed elsewhere within the record type definition that declares the element. 2. The use of a name that denotes a record element as an- other element within the record type definition is not allowed. If the sentence is interpreted as 1, this test is a good "expect failure" test because the record element name x is used within the record type definition rec_type (as the sub- type indication of the record element z). However, if it is interpreted as 2, this should be an "expect success" test because the name x can be used as the subtype indication of the element z and x has already been defined. -- ##32202311441FF******************************************************** --+ File: [SUITE.CH03.S02.S2]02030101.VHD -- --+ Copyright: (c) 1987, 1988 by CAD Language Systems, Inc. All rights reserve -- --+ LRM_version: IEEE Std. 1076-1987 -- --+ Subsets: -- --+ Description: -- --+ Test_point - (030220_020301) "The use of a name that denotes a record -- element is not allowed within the record type definition that declares -- the element." -- --+ Test_objective (1)- Test that the use of a name that denotes a record -- element is not allowed within the record type definition that declares -- the element. -- This test should indicate an error because the element 'x' has been -- used in another element ('z') declaration, which is illegal. -- --+ References : None -- --+ Instructions: None -- --+ Keywords: record type definition -- --+ Test_Results: Expect_Failure . Output_checked. Approximate Error Message: -- "The use of a name that denotes a record element is not allowed within the -- record type definition that declares the element." -- --+ Test_type: Locally Static Semantic -- --+ History: Created /CLSI 08-30-88 -- Modified RA/Vtech 04-15-89 -- Corrected CHC/Vtech 12-3-90 -- --+ Comments: CLSI-FILE : [000000.TYPES.RECORD]03 -- --**************************************************************************- ** package mt3 is type x is (one,two); type rec_type is record x : bit; y : integer; z : x; -- Failure_here -- ERROR: The use of a name that denotes a record element is not allowed -- within the record type definition that declares the element. end record; end mt3; Proposed Resolution ------------------- TBD VASG-ISAC Analysis & Rationale ------------------------------ Actually there are three ways of interpreting the LRM (3.2.2) in this case: 1). Most strict. The use of a name which is used to denote an element of a record is not allowed ANY WHERE in that record. So for example, this code is in error: ... type t is (qfm, qlm); type r_c is record x : t; -- this line in error since 't' is a name t : integer; -- of an element of the record. end record; ... or, 2). Less retentive, where the use of a name which is used to denote an element of a record is not allowed AFTER it is USED to declare a name of an element. So for example, this code will be in error: ... type t is (qfm, qlm); type y is (WillItWork, WillItFail); type r_c is record x : t; -- this line is now OK! t : integer; y : y; -- but not this line. y used as a name of an -- element. Any other use is now restricted. end record; ... finally, 3). Most permissive, which will disallow the use of the name of an element only after it is DECLARED. The declaration of the name will come into effect after the semicolon. So, for example: ... type x is (go, nogo); type t is (qfm, qlm); type y is (WillItWork, WillItFail); type r_c is record x : t; -- this line is now OK! t : integer; y : y; -- This is OK too. z : x; -- This is an error in any case!! end record; ... VASG-ISAC Recommendation for IEEE Std 1076-1987 ----------------------------------------------- We feel the language in the LRM (strictly speaking) supports the first case, but that such interpretation is not resonable and not desired. Our feeling is then, that the second interpretation be assumed and that section 3.2.2, (first paragraph after the syntax summery) should read as if it was written: "Each element declaration declares an element of the record type. The identifiers of all elements of a record type must be distinct. The use of a name that denotes a record element is not allowed within the record type definition that declares the element after that name (of the element) is first used in the declaration of an element." VASG-ISAC Recommendation for Future Revisions --------------------------------------------- The restriction should be relaxed and reflect more the implementation of a hierarchycal symbol table. The name should not be allowed to be used after the declaration of the name (i.e the ending semicolon of the element declaration). section 3.2.2, (first paragraph after the syntax summery) should be rewritten: "Each element declaration declares an element of the record type. The identifiers of all elements of a record type must be distinct. The use of a name that denotes a record element is not allowed within the record type definition that declares the element after that name is declared."