From: Paolo Carlini Date: Tue, 8 Jan 2019 09:41:36 +0000 (+0000) Subject: decl.c (start_decl): Improve permerror location. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=30fa2068a3d4317b5b2282eb2e37e98aedfcbf4e;p=gcc.git decl.c (start_decl): Improve permerror location. /cp 2019-01-08 Paolo Carlini * decl.c (start_decl): Improve permerror location. /testsuite 2019-01-08 Paolo Carlini * g++.dg/diagnostic/out-of-class-redeclaration.C: New. From-SVN: r267675 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 32c7f40b212..f8d3d939848 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2019-01-08 Paolo Carlini + + * decl.c (start_decl): Improve permerror location. + 2019-01-08 Jonathan Wakely Jakub Jelinek diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f456c070dcd..7e4e93c4201 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5202,7 +5202,8 @@ start_decl (const cp_declarator *declarator, if (DECL_EXTERNAL (decl) && ! DECL_TEMPLATE_SPECIALIZATION (decl) /* Aliases are definitions. */ && !alias) - permerror (input_location, "declaration of %q#D outside of class is not definition", + permerror (declarator->id_loc, + "declaration of %q#D outside of class is not definition", decl); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 48a6a53f24c..bc940878b3f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-01-08 Paolo Carlini + + * g++.dg/diagnostic/out-of-class-redeclaration.C: New. + 2019-01-08 Iain Sandoe * c-c++-common/builtin-has-attribute-3.c: Skip tests requiring symbol diff --git a/gcc/testsuite/g++.dg/diagnostic/out-of-class-redeclaration.C b/gcc/testsuite/g++.dg/diagnostic/out-of-class-redeclaration.C new file mode 100644 index 00000000000..9dba8eb47a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/out-of-class-redeclaration.C @@ -0,0 +1,13 @@ +// Adapted from g++.old-deja/g++.law/arm8.C + +struct K { + void f(int); +}; + +void K::f(int); // { dg-error "6:declaration of .void K::f\\(int\\). outside of class" } + +struct L { + void g(int) {} +}; + +void L::g(int); // { dg-error "6:declaration of .void L::g\\(int\\). outside of class" }