(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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127636
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-08-19 Roger Sayle <roger@eyesopen.com>
+
+ * 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 <burnus@net-b.de>
* gfortran.h (gfc_is_intrinsic_typename): Add declaration.
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
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);
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),
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 ************************/