diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ed172470f4c..9866466d708 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2007-08-19 Roger Sayle + + * match.c (intrinsic_operators): Make static. + (gfc_op2string): New function for converting a gfc_intrinsic_op to + to a "const char*", replacing the macro of the same name. + * gfortran.h (intrinsic_operators): Delete prototype. + (gfc_op2string): Replace macro with function prototype. + 2007-08-18 Tobias Burnus * gfortran.h (gfc_is_intrinsic_typename): Add declaration. diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 01b9d93330d..11d7adce8f7 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -209,10 +209,6 @@ typedef enum gfc_intrinsic_op; -/* Strings for all intrinsic operators. */ -extern mstring intrinsic_operators[]; - - /* This macro is the number of intrinsic operators that exist. Assumptions are made about the numbering of the interface_op enums. */ #define GFC_INTRINSIC_OPS GFC_INTRINSIC_END @@ -1962,10 +1958,7 @@ void gfc_clear_ts (gfc_typespec *); FILE *gfc_open_file (const char *); const char *gfc_basic_typename (bt); const char *gfc_typename (gfc_typespec *); - -#define gfc_op2string(OP) (OP == INTRINSIC_ASSIGN ? \ - "=" : gfc_code2string (intrinsic_operators, OP)) - +const char *gfc_op2string (gfc_intrinsic_op); const char *gfc_code2string (const mstring *, int); int gfc_string2code (const mstring *, const char *); const char *gfc_intent_string (sym_intent); diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 5f56948e0f6..67fbd4fc503 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -30,7 +30,7 @@ along with GCC; see the file COPYING3. If not see unary operators /must/ precede the binary plus and minus, or the expression parser breaks. */ -mstring intrinsic_operators[] = { +static mstring intrinsic_operators[] = { minit ("+", INTRINSIC_UPLUS), minit ("-", INTRINSIC_UMINUS), minit ("+", INTRINSIC_PLUS), @@ -60,6 +60,80 @@ mstring intrinsic_operators[] = { minit (NULL, INTRINSIC_NONE) }; +/* For debugging and diagnostic purposes. Return the textual representation + of the intrinsic operator OP. */ +const char * +gfc_op2string (gfc_intrinsic_op op) +{ + switch (op) + { + case INTRINSIC_UPLUS: + case INTRINSIC_PLUS: + return "+"; + + case INTRINSIC_UMINUS: + case INTRINSIC_MINUS: + return "-"; + + case INTRINSIC_POWER: + return "**"; + case INTRINSIC_CONCAT: + return "//"; + case INTRINSIC_TIMES: + return "*"; + case INTRINSIC_DIVIDE: + return "/"; + + case INTRINSIC_AND: + return ".and."; + case INTRINSIC_OR: + return ".or."; + case INTRINSIC_EQV: + return ".eqv."; + case INTRINSIC_NEQV: + return ".neqv."; + + case INTRINSIC_EQ_OS: + return ".eq."; + case INTRINSIC_EQ: + return "=="; + case INTRINSIC_NE_OS: + return ".ne."; + case INTRINSIC_NE: + return "/="; + case INTRINSIC_GE_OS: + return ".ge."; + case INTRINSIC_GE: + return ">="; + case INTRINSIC_LE_OS: + return ".le."; + case INTRINSIC_LE: + return "<="; + case INTRINSIC_LT_OS: + return ".lt."; + case INTRINSIC_LT: + return "<"; + case INTRINSIC_GT_OS: + return ".gt."; + case INTRINSIC_GT: + return ">"; + case INTRINSIC_NOT: + return ".not."; + + case INTRINSIC_ASSIGN: + return "="; + + case INTRINSIC_PARENTHESES: + return "parens"; + + default: + break; + } + + gfc_internal_error ("gfc_op2string(): Bad code"); + /* Not reached. */ +} + /******************** Generic matching subroutines ************************/