Raymond Toy writes:
> I would think all the places where base-char occur would need to be
> fixed.
I think the only problem is f2cl's guessing that the
array-element-type of a literal string would be BASE-CHAR.
So a minimal test case would be
CHARACTER*1 BAR
PARAMETER (BAR = 'a')
END
I actually investigated this a bit but since my ahem... exposure to
FORTRAN programming is minimal and quite remote I didn't venture to
propose the following patch, which, perhaps, is not completely insane:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: f2cl5.l
===================================================================
RCS file: /cvsroot/clocc/clocc/src/f2cl/src/f2cl5.l,v
retrieving revision 1.121
diff -u -r1.121 f2cl5.l
--- f2cl5.l 15 Aug 2004 11:16:14 -0000 1.121
+++ f2cl5.l 21 Nov 2004 14:22:14 -0000
@@ -1946,8 +1946,8 @@
;; scalar, no length spec.
;;(format t "scalar, no length spec = ~A~%" decl)
(if (equal (cadr type) '(*))
- `(declare (type (simple-array base-char (*)) ,(car decl)))
- `(declare (type (simple-array base-char (,(cadr type))) ,(car decl)))))
+ `(declare (type (simple-string *) ,(car decl)))
+ `(declare (type (simple-string ,(cadr type)) ,(car decl)))))
((atom (cadr decl))
;; scalar, length spec.
;;(format t "scalar, length spec = ~A~%" decl)
@@ -1957,14 +1957,12 @@
((equal (cadr decl) '(*))
;; unspecified length spec
;;(format t "unspecified length spec = ~A~%" decl)
- `(declare (type (simple-array base-char (*)) ,(car decl))))
+ `(declare (type (simple-string *) ,(car decl))))
(t
;; array, no length spec.
;;(format t "array, no length spec = ~A~%" decl)
`(declare (type (,*array-type*
- (simple-array base-char ,(if (second type)
- `(,(second type))
- '(*)))
+ (simple-string ,(or (second type) '*))
,(decl-bounds (rest decl))) ,(car decl)))))))
(defun make-char-init (decl type)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I also considered some test cases
CHARACTER*1 FOO1
C$$$ CHARACTER*1 FOO2*2
CHARACTER*1 FOO3*(*)
CHARACTER*(*) FOO11
C$$$ CHARACTER*(*) FOO21*2
CHARACTER*(*) FOO31*(*)
CHARACTER*1 AFOO1(2)
C$$$ CHARACTER*1 AFOO2(2)*2
C$$$ CHARACTER*(*) AFOO21(2)*2
END
I think f2cl still doesn't like the commented-out ones although g77
accepts some of them. Of course, it's also quite possible that some
of the declarations are illegal.
Wolfgang