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] Use explicit UNKNOWN_LOCATION instead of input_location (which is line 1) for process_options diagnostics (PR c/68656)


Hi!

As mentioned in the PR, the process_options diagnostics is about errors
on the command line (incompatible options, unsupported options etc.),
which aren't really related to any source code location.
This patch fixes it to use explicit UNKNOWN_LOCATION, instead of
explicit or implicit input_location, which for most of process_options
is somewhere on line 1 of the main source file.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Quick grep seems to suggest some other spots that should be using
UNKNOWN_LOCATION, will leave that to backend maintainers.

gcc/testsuite/gcc.target/s390/hotpatch-compile-4.c:/* { dg-error "arguments to .-mhotpatch=n,m. should be non-negative integers" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/s390/hotpatch-compile-1.c:/* { dg-error "arguments to .-mhotpatch=n,m. should be non-negative integers" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/s390/hotpatch-compile-2.c:/* { dg-error "arguments to .-mhotpatch=n,m. should be non-negative integers" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/s390/hotpatch-compile-6.c:/* { dg-error "arguments to .-mhotpatch=n,m. should be non-negative integers" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/s390/hotpatch-compile-3.c:/* { dg-error "arguments to .-mhotpatch=n,m. should be non-negative integers" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/s390/hotpatch-compile-14.c:/* { dg-error "argument to .-mhotpatch=n,m. is too large" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/s390/hotpatch-compile-5.c:/* { dg-error "arguments to .-mhotpatch=n,m. should be non-negative integers" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/m68k/stack-limit-1.c:/* { dg-warning "not supported" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/powerpc/warn-2.c:/* { dg-warning "-mno-altivec disables vsx" "" { target *-*-* } 1 } */
gcc/testsuite/gcc.target/powerpc/warn-1.c:/* { dg-warning "-mvsx and -mno-altivec are incompatible" "" { target *-*-* } 1 } */

2015-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR c/68656
	* toplev.c (init_asm_output): Pass UNKNOWN_LOCATION instead of
	input_location to inform.
	(process_options): Use warning_at (UNKNOWN_LOCATION instead of
	warning ( and error_at (UNKNOWN_LOCATION instead of error (.
	Pass UNKNOWN_LOCATION instead of input_location to fatal_error.

	* gcc.target/i386/pr65044.c: Expect error on line 0 rather than
	line 1.
	* g++.dg/opt/pr34036.C: Expect warning on line 0 rather than line 1.
	* gcc.dg/tree-ssa/pr23109.c: Likewise.
	* gcc.dg/tree-ssa/recip-5.c: Likewise.
	* gcc.dg/pr33007.c: Likewise.

--- gcc/toplev.c.jj	2015-12-02 20:26:56.000000000 +0100
+++ gcc/toplev.c	2015-12-04 15:04:24.503513214 +0100
@@ -904,7 +904,9 @@ init_asm_output (const char *name)
 						   NULL);
 	    }
 	  else
-	    inform (input_location, "-frecord-gcc-switches is not supported by the current target");
+	    inform (UNKNOWN_LOCATION,
+		    "-frecord-gcc-switches is not supported by "
+		    "the current target");
 	}
 
       if (flag_verbose_asm)
@@ -1214,8 +1216,9 @@ process_options (void)
 
   if (flag_section_anchors && !target_supports_section_anchors_p ())
     {
-      warning (OPT_fsection_anchors,
-	       "this target does not support %qs", "-fsection-anchors");
+      warning_at (UNKNOWN_LOCATION, OPT_fsection_anchors,
+		  "this target does not support %qs",
+		  "-fsection-anchors");
       flag_section_anchors = 0;
     }
 
@@ -1250,14 +1253,16 @@ process_options (void)
     {
       if (targetm.chkp_bound_mode () == VOIDmode)
 	{
-	  error ("-fcheck-pointer-bounds is not supported for this target");
+	  error_at (UNKNOWN_LOCATION,
+		    "-fcheck-pointer-bounds is not supported for this target");
 	  flag_check_pointer_bounds = 0;
 	}
 
       if (flag_sanitize & SANITIZE_ADDRESS)
 	{
-	  error ("-fcheck-pointer-bounds is not supported with "
-		 "Address Sanitizer");
+	  error_at (UNKNOWN_LOCATION,
+		    "-fcheck-pointer-bounds is not supported with "
+		    "Address Sanitizer");
 	  flag_check_pointer_bounds = 0;
 	}
     }
@@ -1270,7 +1275,8 @@ process_options (void)
   if (!abi_version_at_least (2))
     {
       /* -fabi-version=1 support was removed after GCC 4.9.  */
-      error ("%<-fabi-version=1%> is no longer supported");
+      error_at (UNKNOWN_LOCATION,
+		"%<-fabi-version=1%> is no longer supported");
       flag_abi_version = 2;
     }
 
@@ -1297,10 +1303,12 @@ process_options (void)
   /* Warn about options that are not supported on this machine.  */
 #ifndef INSN_SCHEDULING
   if (flag_schedule_insns || flag_schedule_insns_after_reload)
-    warning (0, "instruction scheduling not supported on this target machine");
+    warning_at (UNKNOWN_LOCATION, 0,
+		"instruction scheduling not supported on this target machine");
 #endif
   if (!DELAY_SLOTS && flag_delayed_branch)
-    warning (0, "this target machine does not have delayed branches");
+    warning_at (UNKNOWN_LOCATION, 0,
+		"this target machine does not have delayed branches");
 
   user_label_prefix = USER_LABEL_PREFIX;
   if (flag_leading_underscore != -1)
@@ -1313,8 +1321,9 @@ process_options (void)
 	  user_label_prefix = flag_leading_underscore ? "_" : "";
 	}
       else
-	warning (0, "-f%sleading-underscore not supported on this target machine",
-		 flag_leading_underscore ? "" : "no-");
+	warning_at (UNKNOWN_LOCATION, 0,
+		    "-f%sleading-underscore not supported on this "
+		    "target machine", flag_leading_underscore ? "" : "no-");
     }
 
   /* If we are in verbose mode, write out the version and maybe all the
@@ -1350,14 +1359,16 @@ process_options (void)
       FILE *final_output = fopen (flag_dump_final_insns, "w");
       if (!final_output)
 	{
-	  error ("could not open final insn dump file %qs: %m",
-		 flag_dump_final_insns);
+	  error_at (UNKNOWN_LOCATION,
+		    "could not open final insn dump file %qs: %m",
+		    flag_dump_final_insns);
 	  flag_dump_final_insns = NULL;
 	}
       else if (fclose (final_output))
 	{
-	  error ("could not close zeroed insn dump file %qs: %m",
-		 flag_dump_final_insns);
+	  error_at (UNKNOWN_LOCATION,
+		    "could not close zeroed insn dump file %qs: %m",
+		    flag_dump_final_insns);
 	  flag_dump_final_insns = NULL;
 	}
     }
@@ -1392,8 +1403,9 @@ process_options (void)
     debug_hooks = &dwarf2_lineno_debug_hooks;
 #endif
   else
-    error ("target system does not support the %qs debug format",
-	   debug_type_names[write_symbols]);
+    error_at (UNKNOWN_LOCATION,
+	      "target system does not support the %qs debug format",
+	      debug_type_names[write_symbols]);
 
   /* We know which debug output will be used so we can set flag_var_tracking
      and flag_var_tracking_uninit if the user has not specified them.  */
@@ -1404,11 +1416,13 @@ process_options (void)
 	  || flag_var_tracking_uninit == 1)
         {
 	  if (debug_info_level < DINFO_LEVEL_NORMAL)
-	    warning (0, "variable tracking requested, but useless unless "
-		     "producing debug info");
+	    warning_at (UNKNOWN_LOCATION, 0,
+			"variable tracking requested, but useless unless "
+			"producing debug info");
 	  else
-	    warning (0, "variable tracking requested, but not supported "
-		     "by this debug format");
+	    warning_at (UNKNOWN_LOCATION, 0,
+			"variable tracking requested, but not supported "
+			"by this debug format");
 	}
       flag_var_tracking = 0;
       flag_var_tracking_uninit = 0;
@@ -1444,7 +1458,8 @@ process_options (void)
 
   if (flag_var_tracking_assignments
       && (flag_selective_scheduling || flag_selective_scheduling2))
-    warning (0, "var-tracking-assignments changes selective scheduling");
+    warning_at (UNKNOWN_LOCATION, 0,
+		"var-tracking-assignments changes selective scheduling");
 
   if (flag_tree_cselim == AUTODETECT_VALUE)
     {
@@ -1461,31 +1476,37 @@ process_options (void)
     {
       aux_info_file = fopen (aux_info_file_name, "w");
       if (aux_info_file == 0)
-	fatal_error (input_location, "can%'t open %s: %m", aux_info_file_name);
+	fatal_error (UNKNOWN_LOCATION,
+		     "can%'t open %s: %m", aux_info_file_name);
     }
 
   if (!targetm_common.have_named_sections)
     {
       if (flag_function_sections)
 	{
-	  warning (0, "-ffunction-sections not supported for this target");
+	  warning_at (UNKNOWN_LOCATION, 0,
+		      "-ffunction-sections not supported for this target");
 	  flag_function_sections = 0;
 	}
       if (flag_data_sections)
 	{
-	  warning (0, "-fdata-sections not supported for this target");
+	  warning_at (UNKNOWN_LOCATION, 0,
+		      "-fdata-sections not supported for this target");
 	  flag_data_sections = 0;
 	}
     }
 
   if (flag_prefetch_loop_arrays > 0 && !targetm.code_for_prefetch)
     {
-      warning (0, "-fprefetch-loop-arrays not supported for this target");
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-fprefetch-loop-arrays not supported for this target");
       flag_prefetch_loop_arrays = 0;
     }
   else if (flag_prefetch_loop_arrays > 0 && !targetm.have_prefetch ())
     {
-      warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)");
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-fprefetch-loop-arrays not supported for this target "
+		  "(try -march switches)");
       flag_prefetch_loop_arrays = 0;
     }
 
@@ -1493,7 +1514,8 @@ process_options (void)
      make much sense anyway, so don't allow it.  */
   if (flag_prefetch_loop_arrays > 0 && optimize_size)
     {
-      warning (0, "-fprefetch-loop-arrays is not supported with -Os");
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-fprefetch-loop-arrays is not supported with -Os");
       flag_prefetch_loop_arrays = 0;
     }
 
@@ -1504,7 +1526,9 @@ process_options (void)
   /* We cannot reassociate if we want traps or signed zeros.  */
   if (flag_associative_math && (flag_trapping_math || flag_signed_zeros))
     {
-      warning (0, "-fassociative-math disabled; other options take precedence");
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-fassociative-math disabled; other options take "
+		  "precedence");
       flag_associative_math = 0;
     }
 
@@ -1520,7 +1544,8 @@ process_options (void)
      target already uses a soft frame pointer, the transition is trivial.  */
   if (!FRAME_GROWS_DOWNWARD && flag_stack_protect)
     {
-      warning (0, "-fstack-protector not supported for this target");
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-fstack-protector not supported for this target");
       flag_stack_protect = 0;
     }
   if (!flag_stack_protect)
@@ -1531,16 +1556,17 @@ process_options (void)
   if ((flag_sanitize & SANITIZE_ADDRESS)
       && !FRAME_GROWS_DOWNWARD)
     {
-      warning (0,
-	       "-fsanitize=address and -fsanitize=kernel-address "
-	       "are not supported for this target");
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-fsanitize=address and -fsanitize=kernel-address "
+		  "are not supported for this target");
       flag_sanitize &= ~SANITIZE_ADDRESS;
     }
 
   if ((flag_sanitize & SANITIZE_USER_ADDRESS)
       && targetm.asan_shadow_offset == NULL)
     {
-      warning (0, "-fsanitize=address not supported for this target");
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "-fsanitize=address not supported for this target");
       flag_sanitize &= ~SANITIZE_ADDRESS;
     }
 
--- gcc/testsuite/gcc.target/i386/pr65044.c.jj	2015-03-14 09:49:40.000000000 +0100
+++ gcc/testsuite/gcc.target/i386/pr65044.c	2015-12-04 17:04:13.809624910 +0100
@@ -1,7 +1,7 @@
-/* { dg-error "-fcheck-pointer-bounds is not supported with Address Sanitizer" } */
 /* { dg-do compile } */
 /* { dg-require-effective-target mpx } */
 /* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */
+/* { dg-error "-fcheck-pointer-bounds is not supported with Address Sanitizer" "" { target *-*-* } 0 } */
 
 extern int x[];
 
--- gcc/testsuite/g++.dg/opt/pr34036.C.jj	2008-09-05 12:55:03.000000000 +0200
+++ gcc/testsuite/g++.dg/opt/pr34036.C	2015-12-04 17:04:49.636121489 +0100
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fnon-call-exceptions -ffast-math -fsignaling-nans" } */
-/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 1 } */
+/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 0 } */
 
 template <class T>
 class ggStaticArray {
--- gcc/testsuite/gcc.dg/tree-ssa/pr23109.c.jj	2015-11-26 10:40:58.000000000 +0100
+++ gcc/testsuite/gcc.dg/tree-ssa/pr23109.c	2015-12-04 17:02:40.524935713 +0100
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -funsafe-math-optimizations -ftrapping-math -fdump-tree-recip -fdump-tree-lim2" } */
-/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 1 } */
+/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 0 } */
 
 double F[2] = { 0., 0. }, e = 0.;
 
--- gcc/testsuite/gcc.dg/tree-ssa/recip-5.c.jj	2015-05-29 15:03:44.000000000 +0200
+++ gcc/testsuite/gcc.dg/tree-ssa/recip-5.c	2015-12-04 17:03:24.348319923 +0100
@@ -1,6 +1,6 @@
 /* { dg-options "-O1 -funsafe-math-optimizations -ftrapping-math -fdump-tree-recip -fdump-tree-optimized" } */
 /* { dg-do compile } */
-/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 1 } */
+/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 0 } */
 
 /* Test the reciprocal optimizations together with trapping math.  */
 
--- gcc/testsuite/gcc.dg/pr33007.c.jj	2008-09-05 12:54:36.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr33007.c	2015-12-04 17:02:17.151264152 +0100
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O -ffast-math -ftrapping-math" } */
-/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 1 } */
+/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 0 } */
 
 long
 foo (int i)

	Jakub


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