diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2005-06-06 14:18:22 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2005-06-06 14:18:22 +0000 |
commit | b2a9b2086a4e4b9abe394008ba33017aa71e0a24 (patch) | |
tree | b98917533caac2a191d7343327013798ecf8efb1 | |
parent | 3d7b7acc42f12a1d154e53721b979d8d94611bcf (diff) | |
download | gcc-b2a9b2086a4e4b9abe394008ba33017aa71e0a24.zip gcc-b2a9b2086a4e4b9abe394008ba33017aa71e0a24.tar.gz gcc-b2a9b2086a4e4b9abe394008ba33017aa71e0a24.tar.bz2 |
re PR c++/20637 (Confusing message with different using declarations)
cp:
PR c++/20637
* cp-tree.h (add_method): Add using_decl parameter.
* class.c (add_method): Add using_decl parameter. Adjust error
messages.
(handle_using_decl): Pass the using decl to add_method.
(clone_function_decl): Adjust add_member calls.
* decl2.c (check_classfn): Likewise.
* method.c (lazily_declare_fn): Likewise.
* semantics.c (finish_member_declaration): Likewise.
* method.c (synthesize_method): Use inform, not warning.
testsuite:
PR c++/20637
* g++.dg/inherit/using4.C: New.
* g++.dg/overload/error1.C: Adjust expected errors.
* g++.old-deja/g++.benjamin/warn02.C: Likewise.
* g++.old-deja/g++.brendan/arm2.C: Likewise.
* g++.old-deja/g++.other/redecl2.C: Likewise.
* g++.old-deja/g++.other/redecl4.C: Likewise.
* g++.old-deja/g++.pt/memtemp78.C: Likewise.
From-SVN: r100664
-rw-r--r-- | gcc/cp/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/cp/class.c | 50 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 2 | ||||
-rw-r--r-- | gcc/cp/method.c | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/inherit/using4.C | 14 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/overload/error1.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.brendan/arm2.C | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/redecl2.C | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/redecl4.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C | 12 |
14 files changed, 95 insertions, 50 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d965f8b..758451c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2005-06-06 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/20637 + * cp-tree.h (add_method): Add using_decl parameter. + * class.c (add_method): Add using_decl parameter. Adjust error + messages. + (handle_using_decl): Pass the using decl to add_method. + (clone_function_decl): Adjust add_member calls. + * decl2.c (check_classfn): Likewise. + * method.c (lazily_declare_fn): Likewise. + * semantics.c (finish_member_declaration): Likewise. + + * method.c (synthesize_method): Use inform, not warning. + 2005-06-06 Hans-Peter Nilsson <hp@axis.se> * config-lang.in (target_libs): Remove target-gperf. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d982b39..8661931 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -878,12 +878,12 @@ modify_vtable_entry (tree t, } -/* Add method METHOD to class TYPE. */ +/* Add method METHOD to class TYPE. If USING_DECL is non-null, it is + the USING_DECL naming METHOD. */ void -add_method (tree type, tree method) +add_method (tree type, tree method, tree using_decl) { - int using; unsigned slot; tree overload; bool template_conv_p = false; @@ -897,7 +897,6 @@ add_method (tree type, tree method) return; complete_p = COMPLETE_TYPE_P (type); - using = (DECL_CONTEXT (method) != type); conv_p = DECL_CONV_FN_P (method); if (conv_p) template_conv_p = (TREE_CODE (method) == TEMPLATE_DECL @@ -1024,21 +1023,28 @@ add_method (tree type, tree method) || same_type_p (TREE_TYPE (TREE_TYPE (fn)), TREE_TYPE (TREE_TYPE (method))))) { - if (using && DECL_CONTEXT (fn) == type) - /* Defer to the local function. */ - return; + if (using_decl) + { + if (DECL_CONTEXT (fn) == type) + /* Defer to the local function. */ + return; + if (DECL_CONTEXT (fn) == DECL_CONTEXT (method)) + cp_error_at ("repeated using declaration %qD", using_decl); + else + cp_error_at ("using declaration %qD conflicts with a previous using declaration", + using_decl); + } else { - cp_error_at ("%q#D and %q#D cannot be overloaded", - method, fn); - - /* We don't call duplicate_decls here to merge - the declarations because that will confuse - things if the methods have inline - definitions. In particular, we will crash - while processing the definitions. */ - return; + cp_error_at ("%q#D cannot be overloaded", method); + cp_error_at ("with %q#D", fn); } + + /* We don't call duplicate_decls here to merge the + declarations because that will confuse things if the + methods have inline definitions. In particular, we + will crash while processing the definitions. */ + return; } } } @@ -1201,7 +1207,7 @@ handle_using_decl (tree using_decl, tree t) if (flist) for (; flist; flist = OVL_NEXT (flist)) { - add_method (t, OVL_CURRENT (flist)); + add_method (t, OVL_CURRENT (flist), using_decl); alter_access (t, OVL_CURRENT (flist), access); } else @@ -3829,10 +3835,10 @@ clone_function_decl (tree fn, int update_method_vec_p) and a not-in-charge version. */ clone = build_clone (fn, complete_ctor_identifier); if (update_method_vec_p) - add_method (DECL_CONTEXT (clone), clone); + add_method (DECL_CONTEXT (clone), clone, NULL_TREE); clone = build_clone (fn, base_ctor_identifier); if (update_method_vec_p) - add_method (DECL_CONTEXT (clone), clone); + add_method (DECL_CONTEXT (clone), clone, NULL_TREE); } else { @@ -3851,14 +3857,14 @@ clone_function_decl (tree fn, int update_method_vec_p) { clone = build_clone (fn, deleting_dtor_identifier); if (update_method_vec_p) - add_method (DECL_CONTEXT (clone), clone); + add_method (DECL_CONTEXT (clone), clone, NULL_TREE); } clone = build_clone (fn, complete_dtor_identifier); if (update_method_vec_p) - add_method (DECL_CONTEXT (clone), clone); + add_method (DECL_CONTEXT (clone), clone, NULL_TREE); clone = build_clone (fn, base_dtor_identifier); if (update_method_vec_p) - add_method (DECL_CONTEXT (clone), clone); + add_method (DECL_CONTEXT (clone), clone, NULL_TREE); } /* Note that this is an abstract function that is never emitted. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index bcc6b3f..6cf7fa0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3667,7 +3667,7 @@ extern tree build_vfn_ref (tree, tree); extern tree get_vtable_decl (tree, int); extern void resort_type_method_vec (void *, void *, gt_pointer_operator, void *); -extern void add_method (tree, tree); +extern void add_method (tree, tree, tree); extern int currently_open_class (tree); extern tree currently_open_derived_class (tree); extern tree finish_struct (tree, tree); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 48febf7..0501b80 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -709,7 +709,7 @@ check_classfn (tree ctype, tree function, tree template_parms) case we'll only confuse ourselves when the function is declared properly within the class. */ if (COMPLETE_TYPE_P (ctype)) - add_method (ctype, function); + add_method (ctype, function, NULL_TREE); return NULL_TREE; } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index ac85bf4..f5c7d2a 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -806,8 +806,8 @@ synthesize_method (tree fndecl) pop_deferring_access_checks (); if (error_count != errorcount || warning_count != warningcount) - warning (0, "%Hsynthesized method %qD first required here ", - &input_location, fndecl); + inform ("%Hsynthesized method %qD first required here ", + &input_location, fndecl); } /* Use EXTRACTOR to locate the relevant function called for each base & @@ -1119,7 +1119,7 @@ lazily_declare_fn (special_function_kind sfk, tree type) if (sfk == sfk_destructor) check_for_override (fn, type); /* Add it to CLASSTYPE_METHOD_VEC. */ - add_method (type, fn); + add_method (type, fn, NULL_TREE); /* Add it to TYPE_METHODS. */ if (sfk == sfk_destructor && DECL_VIRTUAL_P (fn) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d969a24..76464ad 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2250,7 +2250,7 @@ finish_member_declaration (tree decl) { /* We also need to add this function to the CLASSTYPE_METHOD_VEC. */ - add_method (current_class_type, decl); + add_method (current_class_type, decl, NULL_TREE); TREE_CHAIN (decl) = TYPE_METHODS (current_class_type); TYPE_METHODS (current_class_type) = decl; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e9c45ce9c..9061d5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2005-06-06 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/20637 + * g++.dg/inherit/using4.C: New. + * g++.dg/overload/error1.C: Adjust expected errors. + * g++.old-deja/g++.benjamin/warn02.C: Likewise. + * g++.old-deja/g++.brendan/arm2.C: Likewise. + * g++.old-deja/g++.other/redecl2.C: Likewise. + * g++.old-deja/g++.other/redecl4.C: Likewise. + * g++.old-deja/g++.pt/memtemp78.C: Likewise. + 2005-06-05 David Billinghurst <David.Billinghurst@riotinto.com> * gfortran.dg/f2c_5.f90: Add -w to dg-options diff --git a/gcc/testsuite/g++.dg/inherit/using4.C b/gcc/testsuite/g++.dg/inherit/using4.C new file mode 100644 index 0000000..a0b3873 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/using4.C @@ -0,0 +1,14 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 2005 <nathan@codesourcery.com> + +// PR 20613:uninformative diagnostic +// Origin: Wolfgang Bangerth <bangerth@dealii.org> + +struct B { + void f(); +}; + +struct D : B { + using B::f; + using B::f; // { dg-error "repeated" } +}; diff --git a/gcc/testsuite/g++.dg/overload/error1.C b/gcc/testsuite/g++.dg/overload/error1.C index fcaa445..dd10d90 100644 --- a/gcc/testsuite/g++.dg/overload/error1.C +++ b/gcc/testsuite/g++.dg/overload/error1.C @@ -2,6 +2,6 @@ struct S { - void f () {} - int f () { return 0; } // { dg-error "" "" } + void f () {} // { dg-error "with" "" } + int f () { return 0; } // { dg-error "overloaded" "" } }; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C b/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C index a2599aa..248e1ed 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C @@ -31,16 +31,16 @@ class C class D { public: - int foo2() {return b;} - int foo2() {return b;} // { dg-error "" } + int foo2() {return b;} // { dg-error "with" } + int foo2() {return b;} // { dg-error "overloaded" } int b; }; class E { public: - int foo2(); - int foo2(); // { dg-error "" } + int foo2(); // { dg-error "with" } + int foo2(); // { dg-error "overloaded" } int b; }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C b/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C index 2cfa6b9..fb1ee42 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C @@ -8,12 +8,12 @@ class X { public: - int foo(); - static int foo(); // error: redeclaration// { dg-error "" } .* + int foo(); // { dg-error "with" } + static int foo(); // error: redeclaration// { dg-error "overloaded" } .* }; class Y { public: - static int foo(); - int foo(); // error: redeclaration// { dg-error "" } .* + static int foo(); // { dg-error "with" } + int foo(); // error: redeclaration// { dg-error "overloaded" } .* }; diff --git a/gcc/testsuite/g++.old-deja/g++.other/redecl2.C b/gcc/testsuite/g++.old-deja/g++.other/redecl2.C index 70f703b..0d6ccf6 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/redecl2.C +++ b/gcc/testsuite/g++.old-deja/g++.other/redecl2.C @@ -1,9 +1,9 @@ // { dg-do assemble } struct S { - S(int); - S(int); // { dg-error "" } already declared + S(int); // { dg-error "with" } + S(int); // { dg-error "overloaded" } already declared - ~S(); - ~S(); // { dg-error "" } already declared + ~S();// { dg-error "with" } + ~S(); // { dg-error "overloaded" } already declared }; diff --git a/gcc/testsuite/g++.old-deja/g++.other/redecl4.C b/gcc/testsuite/g++.old-deja/g++.other/redecl4.C index 9b7f8c5..e3355da 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/redecl4.C +++ b/gcc/testsuite/g++.old-deja/g++.other/redecl4.C @@ -1,7 +1,7 @@ // { dg-do assemble } int main() { struct A { - void f(); - void f(); // { dg-error "" } already declared + void f(); // { dg-error "with" } already declared + void f(); // { dg-error "overloaded" } already declared }; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C index cd54f3a..7334835 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C @@ -23,10 +23,10 @@ template struct B<int>; struct C { template <class U> - void f() {} + void f() {} // { dg-error "with" } redeclaration template <class U> - void f() {} // { dg-error "" } redeclaration + void f() {} // { dg-error "overloaded" } redeclaration }; @@ -42,15 +42,15 @@ template struct D<int, double>; template <class T, class U> struct D2 { - void f(T); - void f(U); // { dg-error "" } redeclaration + void f(T); // { dg-error "with" } redeclaration + void f(U); // { dg-error "overloaded" } redeclaration }; template struct D2<int, int>; struct E { - void f(); - void f(); // { dg-error "" } redeclaration + void f(); // { dg-error "with" } redeclaration + void f(); // { dg-error "overloaded" } redeclaration }; |