This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31587] Module files shouldn't be updated if their content doesn't change
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Apr 2007 21:13:30 -0000
- Subject: [Bug fortran/31587] Module files shouldn't be updated if their content doesn't change
- References: <bug-31587-10259@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from fxcoudert at gcc dot gnu dot org 2007-04-20 22:13 -------
(In reply to comment #11)
> Time to CC Janis?
No need. There's nothing a bit of trial-and-error can't help you write :)
The following adds the necessary dejagnu directive, and uses it in a new test.
I guess the MD5 sum should be the same on all platforms, so it's a good test,
although it means the test will need updating every time someone changes the
format of module files :)
Index: lib/gcc-dg.exp
===================================================================
--- lib/gcc-dg.exp (revision 123942)
+++ lib/gcc-dg.exp (working copy)
@@ -455,6 +455,24 @@
}
}
+# Scan Fortran modules for a given regexp.
+#
+# Argument 0 is the module name
+# Argument 1 is the regexp to match
+proc scan-module { args } {
+ set modfilename [string tolower [lindex $args 0]].mod
+ set fd [open $modfilename r]
+ set text [read $fd]
+ close $fd
+
+ upvar 2 name testcase
+ if [regexp -- [lindex $args 1] $text] {
+ pass "$testcase scan-module [lindex $args 1]"
+ } else {
+ fail "$testcase scan-module [lindex $args 1]"
+ }
+}
+
# Verify that the compiler output file exists, invoked via dg-final.
proc output-exists { args } {
# Process an optional target or xfail list.
Index: gfortran.dg/module_md5_1.f90
===================================================================
--- gfortran.dg/module_md5_1.f90 (revision 0)
+++ gfortran.dg/module_md5_1.f90 (revision 0)
@@ -0,0 +1,14 @@
+! Check that we can write a module file, that it has a correct MD5 sum,
+! and that we can read it back.
+!
+! { dg-do compile }
+module foo
+ integer(kind=4), parameter :: pi = 3_4
+end module foo
+
+program test
+ use foo
+ print *, pi
+end program test
+! { dg-final { scan-module "foo" "MD5:18a257e13c90e3872b7b9400c2fc6e4b" } }
+! { dg-final { cleanup-modules "foo" } }
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31587