To: J3 J3/15-169 Subject: TARGET attribute for components From: Van Snyder Reference: 15-007r1 Date: 2015 June 07 1. Introduction =============== The target attribute is not among the attributes allowed by R438 . To associate a pointer with a component of a derived-type object, one must give objects of the type the TARGET attribute. This compromises the opportunities for optimization, as all components thereby have the TARGET attribute. It would be useful, and helpful to optimizers, if the TARGET attribute were allowed for derived-type components. Objections have been raised to this proposition, due to the complicated rules in subclause 12.5.2.4 concerning the relationship of the TARGET attribute, dummy arguments, actual arguments, and pointers. There are, however, only two cases, the first of which has two subcases: (1) The actual argument is a component of a derived-type object, and that component has the TARGET attribute. (a) The dummy argument does not have the TARGET attribute. This is adequately covered by 12.5.2.4p8. (b) The dummy argument has the TARGET attribute. This is adequately covered by 12.5.2.4p9-10,12. (2) The dummmy argument and actual argument are both derived-type objects, necessarily of the same dynamic type. Therefore, if a component of the actual argument has the TARGET attribute, the corresponding component of the dummy argument necessarily also has the TARGET attribute. This is the subject of 12.5.2.4p9-10,12, which paragraphs need attention. 2. Clause 4 and 5 Edits ======================= The effect of these edits is that the specified component of every variable of the type being defined has the TARGET attribute. A specific exclusion is necessary for named constants of the type. [68:19+ R438] Add an alternative to R438 : "<> TARGET" [69:10+ C450+] Insert a constraint: "C450a (R438) If a component has the TARGET attribute, it shall not have the CONTIGUOUS or POINTER attribute." {In light of C452 [69:15] and C562 [106:9], this might not be necessary.} [70:8+ 4.5.4.1p1+] Add a paragraph: "If a component has the TARGET attribute, that component of every variable of the type has the TARGET attribute (5.5.17). That component of a named constant of the type does not have the TARGET attribute." {Since C725 prohibits the to designate a constant, the second sentence might not be necessary. It does not appear to be necessary to constrain against a named constant being of a type that has a subobject with the TARGET attribute. There is no constraint against a named constant being of a type that has a subobject with the POINTER attribute: apparently C725 covers that case as well.} [106:8 C561] Append within the constraint: "or a component declared within a derived type definition." 3. Alternative -- Clause 5 Edits ================================ This alternative does not declare the TARGET attribute for a component of every variable of a derived type. [113:19+ R560] Add an alternative to R560 , an additional syntax rule, and constraints: " <> R560a <> % \smudge \smudge [ % ...] C589a (R560a) Each except the leftmost shall be the name of a component of the derived type of the preceding . C589b (R560a) The first shall be the name of a variable that is previously declared in the scoping unit or accessible by use or host association." [113:20 5.6.15p1] Append a sentence to the paragraph: "If is , and its subobjects." [113:21- NOTE 5.36+] Insert a note: "NOTE 5.36a Unlike a , a is allowed to contain more than one with nonzero rank. Nevertheless, where a in a pointer assignment statement is , it shall conform to the requirements of C618." 4. Clause 12 Edits ================== [299:30-33 12.5.2.4p9] Replace the paragraph, but not the following list: "If the dummy argument does not have the VALUE attribute, and either the effective argument is simply contiguous or the dummy argument is a scalar, or of assumed rank or assumed shape, and does not have the CONTIGUOUS attribute, and the effective argument is not a coindexed object or an array section with a vector subscript, then o If both the effective and dummy arguments have the TARGET attribute, then" [299:34-35 300:1-2 12.5.2.4p9] Indent the list items and make them a sublist of the above-inserted list item. [300:2+ 12.5.2.4p9+] After the list of 12.5.2.4p9, insert o If a component of the dummy argument has the TARGET attribute, then - any pointers associated with that component of the effective argument become associated with that component of the corresponding dummy argument on invocation of the procedure, and - when execution of the procedure completes, any pointers that do not become undefined (16.5.2.5) and are associated with that component of the dummy argument remain associated with that component of the effective argument." [300:3-6 12.5.2.4p10] Replace the paragraph, but not the following list: "If the dummy argument is an explicit-shape array, an assumed-shape array with the CONTIGUOUS attribute, an assumed-rank object with the CONTIGUOUS attribute, or an assumed-size array, and the effective argument is not simply contiguous and is not an array section with a vector subscript, then o If both the effective and dummy arguments have the TARGET attribute, then" [300:7-10 12.5.2.4p10] Indent the list items and make them a sublist of the above-inserted list item. [300:10+ 12.5.2.4p10+] After the list of 12.5.2.4p10, insert o If a component of the dummy argument has the TARGET attribute, then - on invocation of the procedure, whether any pointers associated with that component of the effective argument become associated with that component of the corresponding dummy argument is processor dependent, and - when execution of the procedure completes, the pointer association status of any pointer that is pointer associated with that component of the dummy argument is processor dependent." {12.5.2.4p11 does not need attention because if a component of the dummy argument has the TARGET attribute, that component of the effective argument necessarily also has the TARGET attribute.} [300:14-15 12.5.2.4p12] Replace the paragraph: "If the dummy argument has the VALUE attribute, and either the dummy argument or components of it have the TARGET attribute, any pointers associated with the dummy argument or those components become undefined when execution of the procedure completes."