This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[autovect][patch]Enable fortran to declare a "const" builtin function
- From: Keith Besaw <kbesaw at us dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Dorit Naishlos <DORIT at il dot ibm dot com>
- Date: Tue, 1 Mar 2005 02:42:30 -0600
- Subject: [autovect][patch]Enable fortran to declare a "const" builtin function
The procedure builtin_function in f95-lang.c has an attrs parameter which
is not currently used. This change searches the attrs for a "const"
attribute and if found sets TREE_READONLY to 1 for the builtin function
being declared. The procedure builtin_function in f95-lang.c is assigned
to lang_hooks.builtin_function for fortran which is used to initialize
common builtin functions. The procedure builtin_function in c-decl.c
is assigned to lang-hooks.builtin_function for C and does process the
attribute list in attrs.
Tested on ppc
OK to commit to autovect branch?
2005-03-01 Keith Besaw kbesaw@us.ibm.com
Changelog:
* f95-lang.c(builtin_function): If "const" attribute is passed
then TREE_READONLY is set to 1 in the builtin's new declaration.
Index: fortran/f95-lang.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/f95-lang.c,v
retrieving revision 1.25.2.2
diff -c -3 -p -r1.25.2.2 f95-lang.c
*** fortran/f95-lang.c 30 Jan 2005 18:12:43 -0000 1.25.2.2
--- fortran/f95-lang.c 1 Mar 2005 07:48:36 -0000
*************** builtin_function (const char *name,
*** 682,688 ****
int function_code,
enum built_in_class class,
const char *library_name,
! tree attrs ATTRIBUTE_UNUSED)
{
tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
--- 682,688 ----
int function_code,
enum built_in_class class,
const char *library_name,
! tree attrs)
{
tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
*************** builtin_function (const char *name,
*** 693,698 ****
--- 693,709 ----
pushdecl (decl);
DECL_BUILT_IN_CLASS (decl) = class;
DECL_FUNCTION_CODE (decl) = function_code;
+
+ /* Possibly apply some default attributes to this built-in function.
*/
+ if (attrs)
+ {
+ /* FORNOW the only supported attribute is "const". If others need
+ to be supported then see the more general solution in procedure
+ builtin_function in c-decl.c */
+ if (lookup_attribute ( "const", attrs ))
+ TREE_READONLY (decl) = 1;
+ }
+
return decl;
}