This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran, RFC] Use gfc_warning_now for gfc_warning


Hi all,

this patch uses the unbuffered gfc_warning_now code for gfc_warning, which might be buffered. Looking at the code, I fail to construct a code where buffering would be done - and the buffer be dropped in case of warnings. I used defines to make it simpler to re-instate buffereing in case it will be needed at some point.

Note: For gfc_errors, dropping the buffer *does* happen. I have also not completely investigated gfc_notify_std for the warning case, but the _DEL and _OBS seem to be only issued after nonambiguous code. I wondered whether "goto var = 1" would trigger it, but seemingly "gotovar = 1" is matched before "goto var" as the warning is not triggered.

Regtesting didn't show any failures. Is the patch OK for the trunk? Do you have comments, concerns or similar?

Tobias

PS: After that patch â or, alternatively, Manuel's buffered warning patch - is in, I will add OPT_W* to the gfc_warning. We also have to think about notify_std.
diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c
index 1864145..6c6b7d1 100644
--- a/gcc/fortran/dependency.c
+++ b/gcc/fortran/dependency.c
@@ -956,10 +956,10 @@ gfc_check_argument_var_dependency (gfc_expr *var, sym_intent intent,
 		     If a dependency is found in the case
 		     elemental == ELEM_CHECK_VARIABLE, we will generate
 		     a temporary, so we don't need to bother the user.  */
-		  gfc_warning ("INTENT(%s) actual argument at %L might "
-			       "interfere with actual argument at %L.",
-		   	       intent == INTENT_OUT ? "OUT" : "INOUT",
-		   	       &var->where, &expr->where);
+		  gfc_warning_1 ("INTENT(%s) actual argument at %L might "
+				 "interfere with actual argument at %L.",
+				 intent == INTENT_OUT ? "OUT" : "INOUT",
+				 &var->where, &expr->where);
 		}
 	      return 0;
 	    }
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index 00e9228..a40bdde 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -804,35 +804,6 @@ gfc_increment_error_count (void)
 }
 
 
-/* Issue a warning.  */
-
-void
-gfc_warning (const char *gmsgid, ...)
-{
-  va_list argp;
-
-  if (inhibit_warnings)
-    return;
-
-  warning_buffer.flag = 1;
-  warning_buffer.index = 0;
-  cur_error_buffer = &warning_buffer;
-
-  va_start (argp, gmsgid);
-  error_print (_("Warning:"), _(gmsgid), argp);
-  va_end (argp);
-
-  error_char ('\0');
-
-  if (buffer_flag == 0)
-  {
-    warnings++;
-    if (warnings_are_errors)
-      gfc_increment_error_count();
-  }
-}
-
-
 /* Whether, for a feature included in a given standard set (GFC_STD_*),
    we should issue an error or a warning, or be quiet.  */
 
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 095d526..bb7ed61 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2690,7 +2690,10 @@ void gfc_buffer_error (int);
 
 const char *gfc_print_wide_char (gfc_char_t);
 
-void gfc_warning (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
+/* Contrary to gfc_warning_now, gfc_warning could be buffered. However, it
+   turned out that the buffer is never dropped but always printed.  */
+#define gfc_warning_1 gfc_warning_now_1
+#define gfc_warning gfc_warning_now
 void gfc_warning_now_1 (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
 bool gfc_warning_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
 bool gfc_warning_now (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
diff --git a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f
index 49bf112..510f93e 100644
--- a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f
+++ b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f
@@ -18,7 +18,7 @@
        end do
        call foo j bar
 ! gfc_warning:
-       r2(4) = 0 ! { dg-warning "is out of bounds" }
+       r2(4) = 0 ! { dg-error "is out of bounds" }
        
        goto 3 45
        end
diff --git a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90 b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90
index 8ce4699..efb4508 100644
--- a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90
+++ b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90
@@ -17,7 +17,7 @@
 
        implicit none
 ! gfc_warning:
-1234  complex :: cplx ! { dg-warning "defined but cannot be used" }
+1234  complex :: cplx ! { dg-error "defined but cannot be used" }
       cplx = 20.
 
 ! gfc_warning_now:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]