[PATCH INSTALLED]: Eliminate "protected" keyword et al from FORTRAN dir

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Sat Jul 19 18:08:00 GMT 2008


This patch removes the "protected" macro from gfortran.h and updates all
the locations in the fortran directory where this keyword is used.  (I
also cleaned up the 25 straggler warnings remaining for C++ keywords like
"class" and "private" used as local variables etc in a couple of places).

Patch tested on x86_64-unknown-linux-gnu, no regressions.

Installed on mainline, preapproved by Tobias Burnus:
http://gcc.gnu.org/ml/fortran/2008-07/msg00118.html

		--Kaveh


2008-07-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* gfortran.h (protected): Remove macro.
	* dump-parse-tree.c (show_attr): Avoid C++ keywords.
	* expr.c (gfc_check_pointer_assign): Likewise.
	* interface.c (compare_parameter_protected): Likewise.
	* intrinsic.c (enum class, add_sym, add_sym_0, add_sym_1,
	add_sym_1s, add_sym_1m, add_sym_2, add_sym_2s, add_sym_3,
	add_sym_3ml, add_sym_3red, add_sym_3s, add_sym_4, add_sym_4s,
	add_sym_5s): Likewise.
	* match.c (gfc_match_assignment, gfc_match_pointer_assignment):
	Likewise.
	* module.c (mio_symbol_attribute): Likewise.
	* primary.c (match_variable): Likewise.
	* resolve.c (resolve_equivalence): Likewise.
	* symbol.c (check_conflict, gfc_add_protected, gfc_copy_attr):
	Likewise.
	* trans-types.c (gfc_get_array_type_bounds): Likewise.

diff -rup orig/egcc-SVN20080719/gcc/fortran/gfortran.h egcc-SVN20080719/gcc/fortran/gfortran.h
--- orig/egcc-SVN20080719/gcc/fortran/gfortran.h	2008-07-18 19:55:14.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/gfortran.h	2008-07-19 08:00:54.000000000 +0200
@@ -627,8 +627,6 @@ typedef struct
   ENUM_BITFIELD (save_state) save:2;

   unsigned data:1,		/* Symbol is named in a DATA statement.  */
-    /* FIXME: This macro is temporary until we convert everything.  */
-#define protected is_protected
     is_protected:1,		/* Symbol has been marked as protected.  */
     use_assoc:1,		/* Symbol has been use-associated.  */
     use_only:1,			/* Symbol has been use-associated, with ONLY.  */
diff -rup orig/egcc-SVN20080719/gcc/fortran/dump-parse-tree.c egcc-SVN20080719/gcc/fortran/dump-parse-tree.c
--- orig/egcc-SVN20080719/gcc/fortran/dump-parse-tree.c	2008-06-07 02:00:28.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/dump-parse-tree.c	2008-07-19 08:00:54.000000000 +0200
@@ -570,7 +570,7 @@ show_attr (symbol_attribute *attr)
     fputs (" OPTIONAL", dumpfile);
   if (attr->pointer)
     fputs (" POINTER", dumpfile);
-  if (attr->protected)
+  if (attr->is_protected)
     fputs (" PROTECTED", dumpfile);
   if (attr->value)
     fputs (" VALUE", dumpfile);
diff -rup orig/egcc-SVN20080719/gcc/fortran/expr.c egcc-SVN20080719/gcc/fortran/expr.c
--- orig/egcc-SVN20080719/gcc/fortran/expr.c	2008-07-03 02:00:14.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/expr.c	2008-07-19 08:00:54.000000000 +0200
@@ -3000,7 +3000,7 @@ gfc_check_pointer_assign (gfc_expr *lval
       return FAILURE;
     }

-  if (attr.protected && attr.use_assoc)
+  if (attr.is_protected && attr.use_assoc)
     {
       gfc_error ("Pointer assigment target has PROTECTED "
 		 "attribute at %L", &rvalue->where);
diff -rup orig/egcc-SVN20080719/gcc/fortran/interface.c egcc-SVN20080719/gcc/fortran/interface.c
--- orig/egcc-SVN20080719/gcc/fortran/interface.c	2008-07-03 02:00:14.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/interface.c	2008-07-19 08:00:54.000000000 +0200
@@ -1565,7 +1565,7 @@ compare_parameter_protected (gfc_symbol
   if (actual->expr_type != EXPR_VARIABLE)
     return 1;

-  if (!actual->symtree->n.sym->attr.protected)
+  if (!actual->symtree->n.sym->attr.is_protected)
     return 1;

   if (!actual->symtree->n.sym->attr.use_assoc)
diff -rup orig/egcc-SVN20080719/gcc/fortran/intrinsic.c egcc-SVN20080719/gcc/fortran/intrinsic.c
--- orig/egcc-SVN20080719/gcc/fortran/intrinsic.c	2008-06-20 08:19:02.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/intrinsic.c	2008-07-19 08:12:20.000000000 +0200
@@ -48,7 +48,7 @@ static enum
 { SZ_NOTHING = 0, SZ_SUBS, SZ_FUNCS, SZ_CONVS }
 sizing;

-enum class
+enum klass
 { NO_CLASS = 0, CLASS_ELEMENTAL, CLASS_INQUIRY, CLASS_TRANSFORMATIONAL };

 #define ACTUAL_NO	0
@@ -243,7 +243,7 @@ do_check (gfc_intrinsic_sym *specific, g
      ZABS ZCOS ZEXP ZLOG ZSIN ZSQRT.  */

 static void
-add_sym (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type, int kind,
+add_sym (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type, int kind,
 	 int standard, gfc_check_f check, gfc_simplify_f simplify,
 	 gfc_resolve_f resolve, ...)
 {
@@ -332,7 +332,7 @@ add_sym (const char *name, gfc_isym_id i
    0 arguments.  */

 static void
-add_sym_0 (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_0 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	   int kind, int standard,
 	   try (*check) (void),
 	   gfc_expr *(*simplify) (void),
@@ -374,7 +374,7 @@ add_sym_0s (const char *name, gfc_isym_i
    1 arguments.  */

 static void
-add_sym_1 (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_1 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	   int kind, int standard,
 	   try (*check) (gfc_expr *),
 	   gfc_expr *(*simplify) (gfc_expr *),
@@ -399,7 +399,7 @@ add_sym_1 (const char *name, gfc_isym_id
    1 arguments.  */

 static void
-add_sym_1s (const char *name, gfc_isym_id id, enum class cl, bt type, int kind, int standard,
+add_sym_1s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind, int standard,
 	    try (*check) (gfc_expr *),
 	    gfc_expr *(*simplify) (gfc_expr *),
 	    void (*resolve) (gfc_code *),
@@ -423,7 +423,7 @@ add_sym_1s (const char *name, gfc_isym_i
    function.  MAX et al take 2 or more arguments.  */

 static void
-add_sym_1m (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_1m (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	    int kind, int standard,
 	    try (*check) (gfc_actual_arglist *),
 	    gfc_expr *(*simplify) (gfc_expr *),
@@ -450,7 +450,7 @@ add_sym_1m (const char *name, gfc_isym_i
    2 arguments.  */

 static void
-add_sym_2 (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_2 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	   int kind, int standard,
 	   try (*check) (gfc_expr *, gfc_expr *),
 	   gfc_expr *(*simplify) (gfc_expr *, gfc_expr *),
@@ -477,7 +477,7 @@ add_sym_2 (const char *name, gfc_isym_id
    2 arguments.  */

 static void
-add_sym_2s (const char *name, gfc_isym_id id, enum class cl, bt type, int kind, int standard,
+add_sym_2s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind, int standard,
 	    try (*check) (gfc_expr *, gfc_expr *),
 	    gfc_expr *(*simplify) (gfc_expr *, gfc_expr *),
 	    void (*resolve) (gfc_code *),
@@ -503,7 +503,7 @@ add_sym_2s (const char *name, gfc_isym_i
    3 arguments.  */

 static void
-add_sym_3 (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_3 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	   int kind, int standard,
 	   try (*check) (gfc_expr *, gfc_expr *, gfc_expr *),
 	   gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
@@ -532,7 +532,7 @@ add_sym_3 (const char *name, gfc_isym_id
    might have to be reordered.  */

 static void
-add_sym_3ml (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_3ml (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	     int kind, int standard,
 	     try (*check) (gfc_actual_arglist *),
 	     gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
@@ -561,7 +561,7 @@ add_sym_3ml (const char *name, gfc_isym_
    their argument also might have to be reordered.  */

 static void
-add_sym_3red (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_3red (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	      int kind, int standard,
 	      try (*check) (gfc_actual_arglist *),
 	      gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
@@ -590,7 +590,7 @@ add_sym_3red (const char *name, gfc_isym
    3 arguments.  */

 static void
-add_sym_3s (const char *name, gfc_isym_id id, enum class cl, bt type, int kind, int standard,
+add_sym_3s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind, int standard,
 	    try (*check) (gfc_expr *, gfc_expr *, gfc_expr *),
 	    gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
 	    void (*resolve) (gfc_code *),
@@ -618,7 +618,7 @@ add_sym_3s (const char *name, gfc_isym_i
    4 arguments.  */

 static void
-add_sym_4 (const char *name, gfc_isym_id id, enum class cl, int actual_ok, bt type,
+add_sym_4 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
 	   int kind, int standard,
 	   try (*check) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *),
 	   gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *,
@@ -651,7 +651,7 @@ add_sym_4 (const char *name, gfc_isym_id
    4 arguments.  */

 static void
-add_sym_4s (const char *name, gfc_isym_id id, enum class cl, bt type, int kind, int standard,
+add_sym_4s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind, int standard,
 	    try (*check) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *),
 	    gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *,
 				   gfc_expr *),
@@ -682,7 +682,7 @@ add_sym_4s (const char *name, gfc_isym_i
    5 arguments.  */

 static void
-add_sym_5s (const char *name, gfc_isym_id id, enum class cl, bt type, int kind, int standard,
+add_sym_5s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind, int standard,
 	    try (*check) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *,
 			  gfc_expr *),
 	    gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *,
diff -rup orig/egcc-SVN20080719/gcc/fortran/match.c egcc-SVN20080719/gcc/fortran/match.c
--- orig/egcc-SVN20080719/gcc/fortran/match.c	2008-07-03 02:00:14.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/match.c	2008-07-19 08:00:54.000000000 +0200
@@ -1287,7 +1287,7 @@ gfc_match_assignment (void)
       return MATCH_NO;
     }

-  if (lvalue->symtree->n.sym->attr.protected
+  if (lvalue->symtree->n.sym->attr.is_protected
       && lvalue->symtree->n.sym->attr.use_assoc)
     {
       gfc_current_locus = old_loc;
@@ -1347,7 +1347,7 @@ gfc_match_pointer_assignment (void)
   if (m != MATCH_YES)
     goto cleanup;

-  if (lvalue->symtree->n.sym->attr.protected
+  if (lvalue->symtree->n.sym->attr.is_protected
       && lvalue->symtree->n.sym->attr.use_assoc)
     {
       gfc_error ("Assigning to a PROTECTED pointer at %C");
diff -rup orig/egcc-SVN20080719/gcc/fortran/module.c egcc-SVN20080719/gcc/fortran/module.c
--- orig/egcc-SVN20080719/gcc/fortran/module.c	2008-06-20 08:19:02.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/module.c	2008-07-19 08:00:54.000000000 +0200
@@ -1741,7 +1741,7 @@ mio_symbol_attribute (symbol_attribute *
 	MIO_NAME (ab_attribute) (AB_OPTIONAL, attr_bits);
       if (attr->pointer)
 	MIO_NAME (ab_attribute) (AB_POINTER, attr_bits);
-      if (attr->protected)
+      if (attr->is_protected)
 	MIO_NAME (ab_attribute) (AB_PROTECTED, attr_bits);
       if (attr->value)
 	MIO_NAME (ab_attribute) (AB_VALUE, attr_bits);
@@ -1836,7 +1836,7 @@ mio_symbol_attribute (symbol_attribute *
 	      attr->pointer = 1;
 	      break;
 	    case AB_PROTECTED:
-	      attr->protected = 1;
+	      attr->is_protected = 1;
 	      break;
 	    case AB_VALUE:
 	      attr->value = 1;
diff -rup orig/egcc-SVN20080719/gcc/fortran/primary.c egcc-SVN20080719/gcc/fortran/primary.c
--- orig/egcc-SVN20080719/gcc/fortran/primary.c	2008-07-03 02:00:14.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/primary.c	2008-07-19 08:00:54.000000000 +0200
@@ -2739,7 +2739,7 @@ match_variable (gfc_expr **result, int e
   switch (sym->attr.flavor)
     {
     case FL_VARIABLE:
-      if (sym->attr.protected && sym->attr.use_assoc)
+      if (sym->attr.is_protected && sym->attr.use_assoc)
 	{
 	  gfc_error ("Assigning to PROTECTED variable at %C");
 	  return MATCH_ERROR;
diff -rup orig/egcc-SVN20080719/gcc/fortran/resolve.c egcc-SVN20080719/gcc/fortran/resolve.c
--- orig/egcc-SVN20080719/gcc/fortran/resolve.c	2008-07-18 02:00:35.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/resolve.c	2008-07-19 08:00:54.000000000 +0200
@@ -8962,7 +8962,7 @@ resolve_equivalence (gfc_equiv *eq)

       sym = e->symtree->n.sym;

-      if (sym->attr.protected)
+      if (sym->attr.is_protected)
 	cnt_protected++;
       if (cnt_protected > 0 && cnt_protected != object)
        	{
diff -rup orig/egcc-SVN20080719/gcc/fortran/symbol.c egcc-SVN20080719/gcc/fortran/symbol.c
--- orig/egcc-SVN20080719/gcc/fortran/symbol.c	2008-07-03 02:00:14.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/symbol.c	2008-07-19 08:00:54.000000000 +0200
@@ -344,14 +344,14 @@ check_conflict (symbol_attribute *attr,
     *intent_in = "INTENT(IN)", *intrinsic = "INTRINSIC",
     *intent_out = "INTENT(OUT)", *intent_inout = "INTENT(INOUT)",
     *allocatable = "ALLOCATABLE", *elemental = "ELEMENTAL",
-    *private = "PRIVATE", *recursive = "RECURSIVE",
+    *privat = "PRIVATE", *recursive = "RECURSIVE",
     *in_common = "COMMON", *result = "RESULT", *in_namelist = "NAMELIST",
-    *public = "PUBLIC", *optional = "OPTIONAL", *entry = "ENTRY",
+    *publik = "PUBLIC", *optional = "OPTIONAL", *entry = "ENTRY",
     *function = "FUNCTION", *subroutine = "SUBROUTINE",
     *dimension = "DIMENSION", *in_equivalence = "EQUIVALENCE",
     *use_assoc = "USE ASSOCIATED", *cray_pointer = "CRAY POINTER",
     *cray_pointee = "CRAY POINTEE", *data = "DATA", *value = "VALUE",
-    *volatile_ = "VOLATILE", *protected = "PROTECTED",
+    *volatile_ = "VOLATILE", *is_protected = "PROTECTED",
     *is_bind_c = "BIND(C)", *procedure = "PROCEDURE";
   static const char *threadprivate = "THREADPRIVATE";

@@ -383,9 +383,9 @@ check_conflict (symbol_attribute *attr,
       if (attr->optional)
 	a1 = optional;
       if (attr->access == ACCESS_PRIVATE)
-	a1 = private;
+	a1 = privat;
       if (attr->access == ACCESS_PUBLIC)
-	a1 = public;
+	a1 = publik;
       if (attr->intent != INTENT_UNKNOWN)
 	a1 = intent;

@@ -541,9 +541,9 @@ check_conflict (symbol_attribute *attr,
       goto conflict;
     }

-  conf (protected, intrinsic)
-  conf (protected, external)
-  conf (protected, in_common)
+  conf (is_protected, intrinsic)
+  conf (is_protected, external)
+  conf (is_protected, in_common)

   conf (volatile_, intrinsic)
   conf (volatile_, external)
@@ -558,7 +558,7 @@ check_conflict (symbol_attribute *attr,
   conf (procedure, allocatable)
   conf (procedure, dimension)
   conf (procedure, intrinsic)
-  conf (procedure, protected)
+  conf (procedure, is_protected)
   conf (procedure, target)
   conf (procedure, value)
   conf (procedure, volatile_)
@@ -585,7 +585,7 @@ check_conflict (symbol_attribute *attr,
       conf2 (dummy);
       conf2 (volatile_);
       conf2 (pointer);
-      conf2 (protected);
+      conf2 (is_protected);
       conf2 (target);
       conf2 (external);
       conf2 (intrinsic);
@@ -599,7 +599,7 @@ check_conflict (symbol_attribute *attr,

       if (attr->access == ACCESS_PUBLIC || attr->access == ACCESS_PRIVATE)
 	{
-	  a2 = attr->access == ACCESS_PUBLIC ? public : private;
+	  a2 = attr->access == ACCESS_PUBLIC ? publik : privat;
 	  gfc_error ("%s attribute applied to %s %s at %L", a2, a1,
 	    name, where);
 	  return FAILURE;
@@ -684,7 +684,7 @@ check_conflict (symbol_attribute *attr,
       conf2 (subroutine);
       conf2 (entry);
       conf2 (pointer);
-      conf2 (protected);
+      conf2 (is_protected);
       conf2 (target);
       conf2 (dummy);
       conf2 (in_common);
@@ -976,7 +976,7 @@ gfc_add_protected (symbol_attribute *att
   if (check_used (attr, name, where))
     return FAILURE;

-  if (attr->protected)
+  if (attr->is_protected)
     {
 	if (gfc_notify_std (GFC_STD_LEGACY,
 			    "Duplicate PROTECTED attribute specified at %L",
@@ -985,7 +985,7 @@ gfc_add_protected (symbol_attribute *att
 	  return FAILURE;
     }

-  attr->protected = 1;
+  attr->is_protected = 1;
   return check_conflict (attr, name, where);
 }

@@ -1582,7 +1582,7 @@ gfc_copy_attr (symbol_attribute *dest, s
     goto fail;
   if (src->pointer && gfc_add_pointer (dest, where) == FAILURE)
     goto fail;
-  if (src->protected && gfc_add_protected (dest, NULL, where) == FAILURE)
+  if (src->is_protected && gfc_add_protected (dest, NULL, where) == FAILURE)
     goto fail;
   if (src->save && gfc_add_save (dest, NULL, where) == FAILURE)
     goto fail;
diff -rup orig/egcc-SVN20080719/gcc/fortran/trans-types.c egcc-SVN20080719/gcc/fortran/trans-types.c
--- orig/egcc-SVN20080719/gcc/fortran/trans-types.c	2008-05-19 02:00:11.000000000 +0200
+++ egcc-SVN20080719/gcc/fortran/trans-types.c	2008-07-19 08:00:54.000000000 +0200
@@ -1513,7 +1513,7 @@ gfc_get_array_type_bounds (tree etype, i
 {
   char name[8 + GFC_RANK_DIGITS + GFC_MAX_SYMBOL_LEN];
   tree fat_type, base_type, arraytype, lower, upper, stride, tmp, rtype;
-  const char *typename;
+  const char *type_name;
   int n;

   base_type = gfc_get_array_descriptor_base (dimen);
@@ -1523,11 +1523,11 @@ gfc_get_array_type_bounds (tree etype, i
   if (tmp && TREE_CODE (tmp) == TYPE_DECL)
     tmp = DECL_NAME (tmp);
   if (tmp)
-    typename = IDENTIFIER_POINTER (tmp);
+    type_name = IDENTIFIER_POINTER (tmp);
   else
-    typename = "unknown";
+    type_name = "unknown";
   sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_%.*s", dimen,
-	   GFC_MAX_SYMBOL_LEN, typename);
+	   GFC_MAX_SYMBOL_LEN, type_name);
   TYPE_NAME (fat_type) = get_identifier (name);

   GFC_DESCRIPTOR_TYPE_P (fat_type) = 1;



More information about the Gcc-patches mailing list