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]

Patch: new testsuite entry, testing lineno for label diagnostics


It seems that the lineno for diagnostics on labels is wrong.  It gets
set to the lineno of the next statement for some reason.  The
following new testsuite entry illustrates this as it gets the label
redeclaration error message on the second i++ line instead of the
second label line.

My motivation for caring about this is that I was trying to write a
test for the -Wtraditional warning about label conflicts with
identifiers.  However a correctly (IMO) written test doesn't pass the
testsuite due to the problem shown below.

Okay to install?



2000-08-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* gcc.dg/noncompile/label-lineno-1.c: New test.

diff -rup orig/egcs-CVS20000822/gcc/testsuite/gcc.dg/noncompile/label-lineno-1.c egcs-CVS20000822/gcc/testsuite/gcc.dg/noncompile/label-lineno-1.c
--- orig/egcs-CVS20000822/gcc/testsuite/gcc.dg/noncompile/label-lineno-1.c	Wed Aug 23 11:51:44 2000
+++ egcs-CVS20000822/gcc/testsuite/gcc.dg/noncompile/label-lineno-1.c	Wed Aug 23 11:51:05 2000
@@ -0,0 +1,14 @@
+/* Ensure that diagnostics for labels appear on the correct lineno.
+   by Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/23/2000.  */
+
+int
+foo(int i)
+{
+ my_label:
+
+  i++;
+
+ my_label: /* { dg-error "duplicate label" "label lineno" } */
+
+  i++;
+}

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