From 7e99f74bbbb709c118fef4991219f83e55bc9b98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez?= Date: Wed, 6 Aug 2008 16:37:06 +0000 Subject: [PATCH] re PR c++/26785 ("extra qualification" error gives line number of end of declaration) 2008-08-06 Manuel Lopez-Ibanez 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. From-SVN: r138816 --- gcc/ChangeLog | 6 ++++++ gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 5 +++-- gcc/diagnostic.c | 24 ++++++++++++++++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/pr26785.C | 10 ++++++++++ gcc/toplev.h | 2 ++ 7 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/pr26785.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e9a060604c08..00b3b7dabdb1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-06 Manuel Lopez-Ibanez + + PR 26785 + * diagnostic.c (permerror_at): New. + * toplev.h (permerror_at): Declare. + 2008-08-06 Victor Kaplansky Ira Rosen diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c55e4b5c3066..4dfd564a7ec5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2008-08-06 Manuel Lopez-Ibanez + + PR 26785 + * decl.c (grokdeclarator): Use explicit location with permerror_at. + 2008-08-06 Manuel Lopez-Ibanez PR 8715 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 69fa647881c1..4c340e28a915 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8437,8 +8437,9 @@ grokdeclarator (const cp_declarator *declarator, 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. */ diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 49b3f9a058ff..69b7e4b534e9 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -554,10 +554,26 @@ pedwarn0 (const char *gmsgid, ...) 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, ...) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ea0a55b2af9f..d1bed88f968c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-06 Manuel Lopez-Ibanez + + PR 26785 + * g++.dg/warn/pr26785.C: New. + 2008-08-06 Victor Kaplansky * gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c: New test. diff --git a/gcc/testsuite/g++.dg/warn/pr26785.C b/gcc/testsuite/g++.dg/warn/pr26785.C new file mode 100644 index 000000000000..b3c0313eaf6b --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr26785.C @@ -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); +}; diff --git a/gcc/toplev.h b/gcc/toplev.h index f1e4fe500f63..1a015e69e0eb 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -68,6 +68,8 @@ 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); -- 2.47.2