From 7797a622445d27891471141a2385c42401ccc099 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 30 May 2019 07:09:41 +0000 Subject: [PATCH] decl.c (grokdeclarator): Use declarator->id_loc in five error_at calls. /cp 2019-05-31 Paolo Carlini * decl.c (grokdeclarator): Use declarator->id_loc in five error_at calls. /testsuite 2019-05-31 Paolo Carlini * g++.dg/cpp0x/alias-decl-18.C: Test location too. * g++.dg/cpp0x/udlit-nofunc-neg.C: Likewise. * g++.dg/parse/crash59.C: Likewise. * g++.dg/parse/error38.C: Likewise. * g++.dg/parse/error39.C: Likewise. * g++.dg/template/crash31.C: Likewise. * g++.dg/template/operator8.C: Likewise. * g++.dg/template/operator9.C: Likewise. From-SVN: r271762 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 15 ++++++++++----- gcc/testsuite/ChangeLog | 11 +++++++++++ gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C | 3 ++- gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C | 4 ++-- gcc/testsuite/g++.dg/parse/crash59.C | 3 ++- gcc/testsuite/g++.dg/parse/error38.C | 2 +- gcc/testsuite/g++.dg/parse/error39.C | 4 ++-- gcc/testsuite/g++.dg/template/crash31.C | 3 ++- gcc/testsuite/g++.dg/template/operator8.C | 3 ++- gcc/testsuite/g++.dg/template/operator9.C | 3 ++- 11 files changed, 41 insertions(+), 15 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 647dd7d5ef6..018139b4b4a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-05-31 Paolo Carlini + + * decl.c (grokdeclarator): Use declarator->id_loc in five + error_at calls. + 2019-05-29 Jakub Jelinek PR c++/90598 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 99d75574d51..bdf397e5ecb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10609,7 +10609,8 @@ grokdeclarator (const cp_declarator *declarator, D1 ( parameter-declaration-clause) ... */ if (funcdef_flag && innermost_code != cdk_function) { - error ("function definition does not declare parameters"); + error_at (declarator->id_loc, + "function definition does not declare parameters"); return error_mark_node; } @@ -10617,7 +10618,8 @@ grokdeclarator (const cp_declarator *declarator, && innermost_code != cdk_function && ! (ctype && !declspecs->any_specifiers_p)) { - error ("declaration of %qD as non-function", dname); + error_at (declarator->id_loc, + "declaration of %qD as non-function", dname); return error_mark_node; } @@ -10626,7 +10628,8 @@ grokdeclarator (const cp_declarator *declarator, if (UDLIT_OPER_P (dname) && innermost_code != cdk_function) { - error ("declaration of %qD as non-function", dname); + error_at (declarator->id_loc, + "declaration of %qD as non-function", dname); return error_mark_node; } @@ -10634,12 +10637,14 @@ grokdeclarator (const cp_declarator *declarator, { if (typedef_p) { - error ("declaration of %qD as %", dname); + error_at (declarator->id_loc, + "declaration of %qD as %", dname); return error_mark_node; } else if (decl_context == PARM || decl_context == CATCHPARM) { - error ("declaration of %qD as parameter", dname); + error_at (declarator->id_loc, + "declaration of %qD as parameter", dname); return error_mark_node; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 60dc28209e9..f25e181bfbf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2019-05-31 Paolo Carlini + + * g++.dg/cpp0x/alias-decl-18.C: Test location too. + * g++.dg/cpp0x/udlit-nofunc-neg.C: Likewise. + * g++.dg/parse/crash59.C: Likewise. + * g++.dg/parse/error38.C: Likewise. + * g++.dg/parse/error39.C: Likewise. + * g++.dg/template/crash31.C: Likewise. + * g++.dg/template/operator8.C: Likewise. + * g++.dg/template/operator9.C: Likewise. + 2019-05-29 Bill Schmidt * gcc.target/powerpc/notoc-direct-1.c: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C index 199b05483f8..1e165d88d8d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C @@ -5,5 +5,6 @@ template using ::T = void(int n); // { dg-error "" } template using operator int = void(int n); // { dg-error "" } template using typename U = void; // { dg-error "" } template using typename ::V = void(int n); // { dg-error "" } -template using typename ::operator bool = void(int n); // { dg-error "" } +template using typename ::operator bool = void(int n); // { dg-error "39:declaration" } +// { dg-error "expected" "" { target *-*-* } .-1 } using foo __attribute__((aligned(4)) = int; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C index 89c7581ff11..861a77ce7bf 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C @@ -3,7 +3,7 @@ // Test user-defined literals. // Test error on non-function declaration. -double operator"" _baddecl; // { dg-error "as non-function" } +double operator"" _baddecl; // { dg-error "8:declaration of .operator\"\"_baddecl. as non-function" } template - int operator"" _badtmpldecl; // { dg-error "as non-function" } + int operator"" _badtmpldecl; // { dg-error "7:declaration of .operator\"\"_badtmpldecl. as non-function" } diff --git a/gcc/testsuite/g++.dg/parse/crash59.C b/gcc/testsuite/g++.dg/parse/crash59.C index e5e62986a3e..7e90dde6c8a 100644 --- a/gcc/testsuite/g++.dg/parse/crash59.C +++ b/gcc/testsuite/g++.dg/parse/crash59.C @@ -1,3 +1,4 @@ // PR c++/53003 -struct A{ void a{} return b // { dg-error "function definition|expected" } +struct A{ void a{} return b // { dg-error "16:function definition" } +// { dg-error "expected" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/g++.dg/parse/error38.C b/gcc/testsuite/g++.dg/parse/error38.C index 63162a8ad84..2c64ed43b43 100644 --- a/gcc/testsuite/g++.dg/parse/error38.C +++ b/gcc/testsuite/g++.dg/parse/error38.C @@ -1,3 +1,3 @@ // PR c++/29003 -typedef int operator !(); // { dg-error "declaration" } +typedef int operator !(); // { dg-error "13:declaration" } diff --git a/gcc/testsuite/g++.dg/parse/error39.C b/gcc/testsuite/g++.dg/parse/error39.C index 431571c12e3..8710e19f87c 100644 --- a/gcc/testsuite/g++.dg/parse/error39.C +++ b/gcc/testsuite/g++.dg/parse/error39.C @@ -1,6 +1,6 @@ // PR c++/41769 -void f(void operator+()); // { dg-error "declaration" } +void f(void operator+()); // { dg-error "13:declaration" } void g() { @@ -8,7 +8,7 @@ void g() { } - catch(void operator+()) // { dg-error "declaration" } + catch(void operator+()) // { dg-error "14:declaration" } { } } diff --git a/gcc/testsuite/g++.dg/template/crash31.C b/gcc/testsuite/g++.dg/template/crash31.C index 2269f47eaad..c8732c81f66 100644 --- a/gcc/testsuite/g++.dg/template/crash31.C +++ b/gcc/testsuite/g++.dg/template/crash31.C @@ -1,3 +1,4 @@ // PR c++/19063 -template void foo() {} // { dg-error "identifier|parameter|template arguments" } + template void foo() {} // { dg-error "14:declaration" } + // { dg-error "expected|template" "" { target *-*-* } .-1 } }; diff --git a/gcc/testsuite/g++.dg/template/operator9.C b/gcc/testsuite/g++.dg/template/operator9.C index d4ebad3aa13..c1303efa4cf 100644 --- a/gcc/testsuite/g++.dg/template/operator9.C +++ b/gcc/testsuite/g++.dg/template/operator9.C @@ -1,6 +1,7 @@ //PR c++/27670 -template void foo(); // { dg-error "before|parameter|template" } +template void foo(); // { dg-error "10:declaration" } +// { dg-error "expected|template" "" { target *-*-* } .-1 } void bar() { -- 2.30.2