From d19f0a18d4fa6dafd6d0f96ce58e50824bfc79ae Mon Sep 17 00:00:00 2001 From: aldyh Date: Mon, 15 Sep 2008 22:24:18 +0000 Subject: [PATCH] testsuite/ * g++.old-deja/g++.brendan/crash16.C: Function name is the correct location for an error regarding a function. * g++.old-deja/g++.other/pmf3.C: Same. * g++.old-deja/g++.law/ctors5.C: Same. * g++.old-deja/g++.pt/explicit34.C: Same. * g++.dg/parse/error28.C: Same. * g++.dg/parse/error17.C: Same. * g++.dg/template/friend44.C: Same. cp/ * decl.c (duplicate_decls): Call error_at. (grokfndecl): New location argument. Use location if available. (grokdeclarator): Pass declarator location to grokfndecl. * cp-tree.h (struct cp_declarator): Update comment for id_loc. * decl2.c (check_classfn): Use error_at. * parser.c (cp_parser_init_declarator): Set function_start_locus to brace location. (cp_parser_member_declaration): Set id_loc for function declarators. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140379 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 11 +++++++++++ gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 20 +++++++++++++++----- gcc/cp/decl2.c | 5 +++-- gcc/cp/parser.c | 12 ++++++++++++ gcc/testsuite/ChangeLog | 11 +++++++++++ gcc/testsuite/g++.dg/parse/error17.C | 2 +- gcc/testsuite/g++.dg/parse/error28.C | 2 +- gcc/testsuite/g++.dg/template/friend44.C | 5 +++-- gcc/testsuite/g++.old-deja/g++.brendan/crash16.C | 4 ++-- gcc/testsuite/g++.old-deja/g++.law/ctors5.C | 2 +- gcc/testsuite/g++.old-deja/g++.other/pmf3.C | 4 ++-- gcc/testsuite/g++.old-deja/g++.pt/explicit34.C | 5 +++-- 13 files changed, 66 insertions(+), 19 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f455a32f07d..5b36ffc1e9c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2008-09-15 Aldy Hernandez + + * decl.c (duplicate_decls): Call error_at. + (grokfndecl): New location argument. Use location if available. + (grokdeclarator): Pass declarator location to grokfndecl. + * cp-tree.h (struct cp_declarator): Update comment for id_loc. + * decl2.c (check_classfn): Use error_at. + * parser.c (cp_parser_init_declarator): Set function_start_locus + to brace location. + (cp_parser_member_declaration): Set id_loc for function declarators. + 2008-09-09 Jan Hubicka PR middle-end/37500 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a39e9da6975..065e47de147 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4089,7 +4089,7 @@ struct cp_declarator { /* For all but cdk_id and cdk_error, the contained declarator. For cdk_id and cdk_error, guaranteed to be NULL. */ cp_declarator *declarator; - location_t id_loc; /* Currently only set for cdk_id. */ + location_t id_loc; /* Currently only set for cdk_id and cdk_function. */ union { /* For identifiers. */ struct { diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d7c70182128..d699f89be32 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1459,7 +1459,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) const char *errmsg = redeclaration_error_message (newdecl, olddecl); if (errmsg) { - error (errmsg, newdecl); + error_at (DECL_SOURCE_LOCATION (newdecl), errmsg, newdecl); if (DECL_NAME (olddecl) != NULL_TREE) error ((DECL_INITIAL (olddecl) && namespace_bindings_p ()) ? "%q+#D previously defined here" @@ -6497,7 +6497,8 @@ grokfndecl (tree ctype, bool funcdef_flag, int template_count, tree in_namespace, - tree* attrlist) + tree* attrlist, + location_t location) { tree decl; int staticp = ctype && TREE_CODE (type) == FUNCTION_TYPE; @@ -6507,6 +6508,12 @@ grokfndecl (tree ctype, type = build_exception_variant (type, raises); decl = build_lang_decl (FUNCTION_DECL, declarator, type); + + /* If we have an explicit location, use it, otherwise use whatever + build_lang_decl used (probably input_location). */ + if (location != UNKNOWN_LOCATION) + DECL_SOURCE_LOCATION (decl) = location; + if (TREE_CODE (type) == METHOD_TYPE) { tree parm; @@ -9018,7 +9025,8 @@ grokdeclarator (const cp_declarator *declarator, virtualp, flags, memfn_quals, raises, friendp ? -1 : 0, friendp, publicp, inlinep, sfk, - funcdef_flag, template_count, in_namespace, attrlist); + funcdef_flag, template_count, in_namespace, + attrlist, declarator->id_loc); if (decl == NULL_TREE) return error_mark_node; #if 0 @@ -9060,7 +9068,8 @@ grokdeclarator (const cp_declarator *declarator, virtualp, flags, memfn_quals, raises, friendp ? -1 : 0, friendp, 1, 0, sfk, funcdef_flag, template_count, in_namespace, - attrlist); + attrlist, + declarator->id_loc); if (decl == NULL_TREE) return error_mark_node; } @@ -9255,7 +9264,8 @@ grokdeclarator (const cp_declarator *declarator, virtualp, flags, memfn_quals, raises, 1, friendp, publicp, inlinep, sfk, funcdef_flag, - template_count, in_namespace, attrlist); + template_count, in_namespace, attrlist, + declarator->id_loc); if (decl == NULL_TREE) return error_mark_node; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a128fb7c5e2..5aecf3c114c 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -638,8 +638,9 @@ check_classfn (tree ctype, tree function, tree template_parms) return OVL_CURRENT (fndecls); } - error ("prototype for %q#D does not match any in class %qT", - function, ctype); + error_at (DECL_SOURCE_LOCATION (function), + "prototype for %q#D does not match any in class %qT", + function, ctype); is_conv_op = DECL_CONV_FN_P (fndecl); if (is_conv_op) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 88f92e7ccc4..f28c76d9177 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -12563,6 +12563,9 @@ cp_parser_init_declarator (cp_parser* parser, } else { + location_t func_brace_location + = cp_lexer_peek_token (parser->lexer)->location; + /* Neither attributes nor an asm-specification are allowed on a function-definition. */ if (asm_specification) @@ -12586,6 +12589,13 @@ cp_parser_init_declarator (cp_parser* parser, = (cp_parser_function_definition_from_specifiers_and_declarator (parser, decl_specifiers, prefix_attributes, declarator)); + if (decl != error_mark_node && DECL_STRUCT_FUNCTION (decl)) + { + /* This is where the prologue starts... */ + DECL_STRUCT_FUNCTION (decl)->function_start_locus + = func_brace_location; + } + return decl; } } @@ -15791,6 +15801,8 @@ cp_parser_member_declaration (cp_parser* parser) return; } else + if (declarator->kind == cdk_function) + declarator->id_loc = token->location; /* Create the declaration. */ decl = grokfield (declarator, &decl_specifiers, initializer, /*init_const_expr_p=*/true, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 09b19726087..028862084d8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2008-09-15 Aldy Hernandez + + * g++.old-deja/g++.brendan/crash16.C: Function name is the correct + location for an error regarding a function. + * g++.old-deja/g++.other/pmf3.C: Same. + * g++.old-deja/g++.law/ctors5.C: Same. + * g++.old-deja/g++.pt/explicit34.C: Same. + * g++.dg/parse/error28.C: Same. + * g++.dg/parse/error17.C: Same. + * g++.dg/template/friend44.C: Same. + 2008-09-13 Raksit Ashok PR rtl-optimization/37489 diff --git a/gcc/testsuite/g++.dg/parse/error17.C b/gcc/testsuite/g++.dg/parse/error17.C index 0e05217c04d..defd708982d 100644 --- a/gcc/testsuite/g++.dg/parse/error17.C +++ b/gcc/testsuite/g++.dg/parse/error17.C @@ -2,7 +2,7 @@ // PR c++/16965 template struct B { - static int Bar(T); // { dg-error "19: error: candidates are: |19: error: " } + static int Bar(T); // { dg-error "14: error: candidates are: |14: error: " } }; struct D : B, B {}; diff --git a/gcc/testsuite/g++.dg/parse/error28.C b/gcc/testsuite/g++.dg/parse/error28.C index fd202a10767..7162afa3a02 100644 --- a/gcc/testsuite/g++.dg/parse/error28.C +++ b/gcc/testsuite/g++.dg/parse/error28.C @@ -3,7 +3,7 @@ struct virt { virt () {} virt (int i) {} }; struct der : public virtual virt { // { dg-error "34: note: der::der" } - der (int i) : virt(i) {} // { dg-error "13: note: candidates are: der" } + der (int i) : virt(i) {} // { dg-error "3: note: candidates are: der" } }; struct top : public der { top () {} // { dg-bogus "der\\(const" } diff --git a/gcc/testsuite/g++.dg/template/friend44.C b/gcc/testsuite/g++.dg/template/friend44.C index a0f63c866ae..04d68c3e0f0 100644 --- a/gcc/testsuite/g++.dg/template/friend44.C +++ b/gcc/testsuite/g++.dg/template/friend44.C @@ -1,8 +1,9 @@ +// { dg-options "-fshow-column" } //PR c++/28260 template struct A { - friend int foo(); // { dg-error "new declaration" } + friend int foo(); // { dg-error "14: error: new declaration" } }; -void foo() { A<0> a; } // { dg-error "ambiguates old declaration" } +void foo() { A<0> a; } // { dg-error "6: error: ambiguates old declaration" } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C index ddcae3c97cb..d05c73b8015 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C @@ -5,10 +5,10 @@ class Graph { // { dg-error "1: error: new types|1: note: \\(perhaps" } public: unsigned char N; - Graph(void) {} // { dg-error "17: error: 'Graph" } + Graph(void) {} // { dg-error "7: error: 'Graph" } } -Graph::Graph(void) // { dg-error "18: error: return type|18: error: redefinition" } +Graph::Graph(void) // { dg-error "18: error: return type|1: error: redefinition" } { N = 10; } diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors5.C b/gcc/testsuite/g++.old-deja/g++.law/ctors5.C index 1f469cf5d49..c9851bf21b7 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/ctors5.C +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors5.C @@ -21,7 +21,7 @@ class Y // { dg-error "1: error: new types may not be defined in a return type|1 public: Y(); } -X::X( int xi ) // { dg-error "14: error: return type specification for constructor invalid|14: note: candidates are: X::X\\(int\\)" } +X::X( int xi ) // { dg-error "14: error: return type specification for constructor invalid|1: note: candidates are: X::X\\(int\\)" } { x = xi; } diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf3.C b/gcc/testsuite/g++.old-deja/g++.other/pmf3.C index e5f757d07af..fa9e92ec998 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/pmf3.C +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf3.C @@ -3,9 +3,9 @@ // Bug: g++ was crashing after giving errors. template - void connect_to_method( + void connect_to_method( // { dg-error "candidates are" } T *receiver, - void (T::*method)()) // { dg-error "candidates are" } + void (T::*method)()) {} class Gtk_Base diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C index 2841ff0525c..f90b4becb17 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C @@ -1,10 +1,11 @@ // { dg-do assemble } +// { dg-options "-fshow-column" } // GROUPS passed templates template void foo(T t); template <> -void foo(int) {}; // { dg-error "" } previously defined here. +void foo(int) {}; // { dg-error "6:" } previously defined here. template <> -void foo(int) {} // { dg-error "" } duplicate specialization. +void foo(int) {} // { dg-error "6:" } duplicate specialization. -- 2.11.4.GIT