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]

PR 26785 "extra qualification" error gives line number of end of declaration


Fix for PR 26785 "extra qualification" error gives line number of end
of declaration
Bootstrapped and regression tested on x86_64-pc-linux-gnu wit
--enable-languages=all.

OK for trunk?


2008-08-05  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
  PR 26785
  * diagnostic.c (permerror_at): New.
  * toplev.h (permerror_at): Declare.
cp/
  * decl.c (grokdeclarator): Use explicit location with permerror_at.
testsuite/

  * g++.dg/warn/pr26785.C: New.
Index: gcc/diagnostic.c
===================================================================
--- gcc/diagnostic.c	(revision 138311)
+++ gcc/diagnostic.c	(working copy)
@@ -552,14 +552,30 @@ pedwarn0 (const char *gmsgid, ...)
                       pedantic_warning_kind ());
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
 
-/* A "permissive" error: issues an error unless -fpermissive was given
-   on the command line, in which case it issues a warning.  Use this
-   for things that really should be errors but we want to support
-   legacy code.  */
+/* A "permissive" error at LOCATION: issues an error unless
+   -fpermissive was given on the command line, in which case it issues
+   a warning.  Use this for things that really should be errors but we
+   want to support legacy code.  */
+
+void
+permerror_at (location_t location, const char *gmsgid, ...)
+{
+  diagnostic_info diagnostic;
+  va_list ap;
+
+  va_start (ap, gmsgid);
+  diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
+		       permissive_error_kind ());
+  diagnostic.option_index = OPT_fpermissive;
+  report_diagnostic (&diagnostic);
+  va_end (ap);
+}
+
+/* Equivalent to permerror_at (input_location, ...).  */
 
 void
 permerror (const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
Index: gcc/toplev.h
===================================================================
--- gcc/toplev.h	(revision 138311)
+++ gcc/toplev.h	(working copy)
@@ -66,10 +66,12 @@ extern void fatal_error (const char *, .
      ATTRIBUTE_NORETURN;
 extern void pedwarn0 (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 /* Pass one of the OPT_W* from options.h as the first parameter.  */
 extern void pedwarn (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
 extern void permerror (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
+extern void permerror_at (location_t, const char *, ...)
+     ATTRIBUTE_GCC_DIAG(2,3);
 extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 
 extern void rest_of_decl_compilation (tree, int, int);
Index: gcc/testsuite/g++.dg/warn/pr26785.C
===================================================================
--- gcc/testsuite/g++.dg/warn/pr26785.C	(revision 0)
+++ gcc/testsuite/g++.dg/warn/pr26785.C	(revision 0)
@@ -0,0 +1,10 @@
+// PR 26785
+// { dg-do compile }
+// { dg-options "-fshow-column" }
+
+class foo {
+  foo::foo // { dg-error "3: error: extra qualification" }
+  (int a, 
+   int b,
+   int c);
+};
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 138311)
+++ gcc/cp/decl.c	(working copy)
@@ -8434,12 +8434,13 @@ grokdeclarator (const cp_declarator *dec
 	    {
 	      permerror ("member functions are implicitly friends of their class");
 	      friendp = 0;
 	    }
 	  else
-	    permerror ("extra qualification %<%T::%> on member %qs",
-		       ctype, name);
+	    permerror_at (declarator->id_loc, 
+			  "extra qualification %<%T::%> on member %qs",
+			  ctype, name);
 	}
       else if (/* If the qualifying type is already complete, then we
 		  can skip the following checks.  */
 	       !COMPLETE_TYPE_P (ctype)
 	       && (/* If the function is being defined, then

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