From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25801 invoked by alias); 3 Nov 2006 16:54:57 -0000 Received: (qmail 25754 invoked by uid 48); 3 Nov 2006 16:54:29 -0000 Date: Fri, 03 Nov 2006 16:54:00 -0000 Subject: [Bug fortran/29697] New: gfortran should use TYPE_QUAL_CONST etc. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-11/txt/msg00206.txt.bz2 List-Id: I came accross this when implementing the volatile statement/attribute (PR29601), where I used: > + if (sym->attr.volatile_) > + TREE_THIS_VOLATILE (decl) = 1; Ian Lance Taylor noted that: "I think you will also want to give DECL a type which is volatile-qualified: build_qualified_type (original_type, TYPE_QUAL_VOLATILE)" tree.h offers: - TYPE_QUAL_CONST - TYPE_QUAL_VOLATILE - TYPE_QUAL_RESTRICT whereas fortran only "uses": DEF_PRIMITIVE_TYPE (BT_VOLATILE_PTR, build_pointer_type (build_qualified_type (void_type_node, TYPE_QUAL_VOLATILE))) I think TYPE_QUAL_CONST should be used for all PARAMETERs (unless I miss something), maybe also for intent(in) pointers etc. Currently, using "const int" in C gives in (-dump-tree-original) "const int" whereas "integer, parameter ::" in Fortran only gives "int". * * * The meaning can be found in the C99 standard (6.7.3): "An object that has volatile-qualified type may be modified in ways unknown to the implementation or have other unknown side effects. Therefore any expression referring to such an object shall be evaluated strictly according to the rules of the abstract machine, as described in 5.1.2.3. Furthermore, at every sequence point the value last stored in the object shall agree with that prescribed by the abstract machine, except as modified by the unknown factors mentioned previously.114) What constitutes an access to an object that has volatile-qualified type is implementation-defined." "An object that is accessed through a restrict-qualified pointer has a special association with that pointer. This association, defined in 6.7.3.1 below, requires that all accesses to that object use, directly or indirectly, the value of that particular pointer.115) The intended use of the restrict qualifier (like the register storage class) is to promote optimization, and deleting all instances of the qualifier from all preprocessing translation units composing a conforming program does not change its meaning (i.e., observable behavior)." (And more detailed and formal in the paragraphs below.) -- Summary: gfortran should use TYPE_QUAL_CONST etc. Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29697