aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>2005-08-11 15:50:13 +0200
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-08-11 13:50:13 +0000
commit8b67b708f159a6776a07d6eec9c44d3dc8ab9f6e (patch)
treed2c54ce8afd0ee3ffde950228cb4b59edbde4431 /libgfortran
parent74b002ba34f1d63cc0130ad44076b462477c631f (diff)
downloadgcc-8b67b708f159a6776a07d6eec9c44d3dc8ab9f6e.zip
gcc-8b67b708f159a6776a07d6eec9c44d3dc8ab9f6e.tar.gz
gcc-8b67b708f159a6776a07d6eec9c44d3dc8ab9f6e.tar.bz2
re PR libfortran/20006 ($ format extension doesn't work)
PR libfortran/20006 * gfortran.h: Add is_main_program member to symbol_attribute. * trans-decl: Add a gfor_fndecl_set_std tree. (gfc_build_builtin_function_decls): Create it. (gfc_generate_function_code): Add this call at the beginning of the main program. * trans.c (gfc_generate_code): Move main_program and attr. * trans.h: Add declaration for gfor_fndecl_set_std. * Makefile.am: Add file runtime/compile_options.c. * Makefile.in: Regenerate. * libgfortran.h: Create structure compile_options_t. Define the compile_options variable and GFC_STD_ macros. * runtime/compile_options.c: New file. * runtime/error.c (notify_std): New function. * runtime/main.c (init): Call init_compile_options during initialization. * io/format.c: Use the new notify_std function for the $ descriptor extension. * gfortran.dg/runtime_warning_1.f90: New test. Co-Authored-By: Steven Bosscher <stevenb@suse.de> From-SVN: r102990
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog15
-rw-r--r--libgfortran/Makefile.am1
-rw-r--r--libgfortran/Makefile.in8
-rw-r--r--libgfortran/io/format.c1
-rw-r--r--libgfortran/libgfortran.h28
-rw-r--r--libgfortran/runtime/compile_options.c61
-rw-r--r--libgfortran/runtime/error.c26
-rw-r--r--libgfortran/runtime/main.c1
8 files changed, 138 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index f64b01d..bbf3355 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,18 @@
+2005-09-11 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+ Steven Bosscher <stevenb@suse.de>
+
+ PR libfortran/20006
+ * Makefile.am: Add file runtime/compile_options.c.
+ * Makefile.in: Regenerate.
+ * libgfortran.h: Create structure compile_options_t. Define the
+ compile_options variable and GFC_STD_ macros.
+ * runtime/compile_options.c: New file.
+ * runtime/error.c (notify_std): New function.
+ * runtime/main.c (init): Call init_compile_options during
+ initialization.
+ * io/format.c: Use the new notify_std function for the $
+ descriptor extension.
+
2005-08-09 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* Makefile.am: Add file intrinsics/tty.c to Makefile process.
* Makefile.in: Regenerate.
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index d5e21c6..4f12f8f 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -94,6 +94,7 @@ runtime/in_unpack_generic.c \
runtime/normalize.c
gfor_src= \
+runtime/compile_options.c \
runtime/environ.c \
runtime/error.c \
runtime/main.c \
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index f69e3b4..ee68562 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -67,8 +67,8 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
toolexeclibLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
-am__objects_1 = environ.lo error.lo main.lo memory.lo pause.lo stop.lo \
- string.lo select.lo
+am__objects_1 = compile_options.lo environ.lo error.lo main.lo \
+ memory.lo pause.lo stop.lo string.lo select.lo
am__objects_2 = all_l4.lo all_l8.lo
am__objects_3 = any_l4.lo any_l8.lo
am__objects_4 = count_4_l4.lo count_8_l4.lo count_4_l8.lo \
@@ -388,6 +388,7 @@ runtime/in_unpack_generic.c \
runtime/normalize.c
gfor_src = \
+runtime/compile_options.c \
runtime/environ.c \
runtime/error.c \
runtime/main.c \
@@ -831,6 +832,9 @@ f2c_specifics.lo: intrinsics/f2c_specifics.F90
.c.lo:
$(LTCOMPILE) -c -o $@ $<
+compile_options.lo: runtime/compile_options.c
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o compile_options.lo `test -f 'runtime/compile_options.c' || echo '$(srcdir)/'`runtime/compile_options.c
+
environ.lo: runtime/environ.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o environ.lo `test -f 'runtime/environ.c' || echo '$(srcdir)/'`runtime/environ.c
diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c
index 229a937..e075eee 100644
--- a/libgfortran/io/format.c
+++ b/libgfortran/io/format.c
@@ -580,6 +580,7 @@ parse_format_list (void)
case FMT_DOLLAR:
get_fnode (&head, &tail, FMT_DOLLAR);
tail->repeat = 1;
+ notify_std (GFC_STD_GNU, "Extension: $ descriptor");
goto between_desc;
case FMT_T:
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index 6db6ef9..de17c2f 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -295,11 +295,25 @@ typedef struct
}
options_t;
-
extern options_t options;
internal_proto(options);
+/* Compile-time options that will influence the library. */
+
+typedef struct
+{
+ int warn_std;
+ int allow_std;
+}
+compile_options_t;
+
+extern compile_options_t compile_options;
+internal_proto(compile_options);
+
+
+
+
/* Structure for statement options. */
typedef struct
@@ -334,6 +348,18 @@ typedef enum
error_codes;
+/* Flags to specify which standard/extension contains a feature.
+ Keep them in sync with their counterparts in gcc/fortran/gfortran.h. */
+#define GFC_STD_LEGACY (1<<6) /* Backward compatibility. */
+#define GFC_STD_GNU (1<<5) /* GNU Fortran extension. */
+#define GFC_STD_F2003 (1<<4) /* New in F2003. */
+/* Note that no features were obsoleted nor deleted in F2003. */
+#define GFC_STD_F95 (1<<3) /* New in F95. */
+#define GFC_STD_F95_DEL (1<<2) /* Deleted in F95. */
+#define GFC_STD_F95_OBS (1<<1) /* Obsoleted in F95. */
+#define GFC_STD_F77 (1<<0) /* Up to and including F77. */
+
+
/* The filename and line number don't go inside the globals structure.
They are set by the rest of the program and must be linked to. */
diff --git a/libgfortran/runtime/compile_options.c b/libgfortran/runtime/compile_options.c
new file mode 100644
index 0000000..5b12419
--- /dev/null
+++ b/libgfortran/runtime/compile_options.c
@@ -0,0 +1,61 @@
+/* Handling of compile-time options that influence the library.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file. (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with libgfortran; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+
+#include "libgfortran.h"
+
+
+/* Useful compile-time options will be stored in here. */
+compile_options_t compile_options;
+
+
+/* Prototypes */
+extern void set_std (GFC_INTEGER_4, GFC_INTEGER_4);
+export_proto(set_std);
+
+
+void
+set_std (GFC_INTEGER_4 warn_std, GFC_INTEGER_4 allow_std)
+{
+ compile_options.warn_std = warn_std;
+ compile_options.allow_std = allow_std;
+}
+
+
+/* Default values for the compile-time options. Keep in sync with
+ gcc/fortran/options.c (gfc_init_options). */
+void
+init_compile_options (void)
+{
+ compile_options.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
+ | GFC_STD_F2003 | GFC_STD_LEGACY;
+ compile_options.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
+ | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU | GFC_STD_LEGACY;
+}
diff --git a/libgfortran/runtime/error.c b/libgfortran/runtime/error.c
index ff91b96..b2f29ac 100644
--- a/libgfortran/runtime/error.c
+++ b/libgfortran/runtime/error.c
@@ -489,3 +489,29 @@ generate_error (int family, const char *message)
runtime_error (message);
}
+
+
+
+/* Possibly issue a warning/error about use of a nonstandard (or deleted)
+ feature. An error/warning will be issued if the currently selected
+ standard does not contain the requested bits. */
+
+try
+notify_std (int std, const char * message)
+{
+ int warning;
+
+ warning = compile_options.warn_std & std;
+ if ((compile_options.allow_std & std) != 0 && !warning)
+ return SUCCESS;
+
+ show_locus ();
+ if (!warning)
+ {
+ st_printf ("Fortran runtime error: %s\n", message);
+ sys_exit (2);
+ }
+ else
+ st_printf ("Fortran runtime warning: %s\n", message);
+ return FAILURE;
+}
diff --git a/libgfortran/runtime/main.c b/libgfortran/runtime/main.c
index d2cedf7..6801aad 100644
--- a/libgfortran/runtime/main.c
+++ b/libgfortran/runtime/main.c
@@ -96,6 +96,7 @@ init (void)
init_variables ();
init_units ();
+ init_compile_options ();
#ifdef DEBUG
/* Check for special command lines. */