aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2008-09-15 22:24:18 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2008-09-15 22:24:18 +0000
commit402b8cf659febc5377dc1680d35a60060ed72799 (patch)
treec7fecdbe7fcb04db014bde6d44be92149b600735 /gcc
parent0eeb22402c9694e375f3a2b9113bcf94d30205cf (diff)
downloadgcc-402b8cf659febc5377dc1680d35a60060ed72799.zip
gcc-402b8cf659febc5377dc1680d35a60060ed72799.tar.gz
gcc-402b8cf659febc5377dc1680d35a60060ed72799.tar.bz2
crash16.C: Function name is the correct location for an error regarding a function.
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. From-SVN: r140379
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.c20
-rw-r--r--gcc/cp/decl2.c5
-rw-r--r--gcc/cp/parser.c12
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/g++.dg/parse/error17.C2
-rw-r--r--gcc/testsuite/g++.dg/parse/error28.C2
-rw-r--r--gcc/testsuite/g++.dg/template/friend44.C5
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/crash16.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.law/ctors5.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/pmf3.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/explicit34.C5
13 files changed, 66 insertions, 19 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f455a32..5b36ffc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,14 @@
+2008-09-15 Aldy Hernandez <aldyh@redhat.com>
+
+ * 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 <jh@suse.cz>
PR middle-end/37500
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index a39e9da..065e47d 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 d7c7018..d699f89 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 a128fb7..5aecf3c 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 88f92e7..f28c76d 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 09b1972..0288620 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2008-09-15 Aldy Hernandez <aldyh@redhat.com>
+
+ * 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 <raksit@google.com>
PR rtl-optimization/37489
diff --git a/gcc/testsuite/g++.dg/parse/error17.C b/gcc/testsuite/g++.dg/parse/error17.C
index 0e05217..defd708 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 <typename T> 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<int>, B<char> {};
diff --git a/gcc/testsuite/g++.dg/parse/error28.C b/gcc/testsuite/g++.dg/parse/error28.C
index fd202a1..7162afa 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 a0f63c8..04d68c3 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<int> 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 ddcae3c..d05c73b 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 1f469cf..c9851bf 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 e5f757d..fa9e92e 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<class T>
- 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 2841ff0..f90b4be 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 <class T>
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>(int) {} // { dg-error "" } duplicate specialization.
+void foo<int>(int) {} // { dg-error "6:" } duplicate specialization.