aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFabien Chêne <fabien@gcc.gnu.org>2013-08-01 21:24:37 +0200
committerPeter Bergner <bergner@gcc.gnu.org>2013-08-01 14:24:37 -0500
commitfb23b69e140ca2448ae7360fe4a71e81e6101aac (patch)
treecd60a00f627c3f9f0d7d19e369f422b4c4290ae0 /gcc
parent12123452e45937b341f187716a2a8343f0908465 (diff)
downloadgcc-fb23b69e140ca2448ae7360fe4a71e81e6101aac.zip
gcc-fb23b69e140ca2448ae7360fe4a71e81e6101aac.tar.gz
gcc-fb23b69e140ca2448ae7360fe4a71e81e6101aac.tar.bz2
re PR c++/54537 (undiagnosed using-declaration conflicting with used function)
gcc/cp/ PR c++/54537 * cp-tree.h: Check OVL_USED with OVERLOAD_CHECK. * name-lookup.c (do_nonmember_using_decl): Make sure we have an OVERLOAD before calling OVL_USED. Call diagnose_name_conflict instead of issuing an error without mentioning the conflicting declaration. libstdc++-v3/ PR c++/54537 * include/tr1/cmath: Remove pow(double,double) overload, remove a duplicated comment about DR 550. Add a comment to explain the issue. * testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc: New. gcc/testsuite/ PR c++/54537 * g++.dg/overload/using3.C: New. * g++.dg/overload/using2.C: Adjust. * g++.dg/lookup/using9.C: Likewise. Co-Authored-By: Peter Bergner <bergner@vnet.ibm.com> From-SVN: r201414
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/name-lookup.c7
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/lookup/using9.C4
-rw-r--r--gcc/testsuite/g++.dg/overload/using2.C8
-rw-r--r--gcc/testsuite/g++.dg/overload/using3.C16
7 files changed, 43 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c275274..e542959 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2013-08-01 Fabien Chêne <fabien@gcc.gnu.org>
+
+ PR c++/54537
+ * cp-tree.h: Check OVL_USED with OVERLOAD_CHECK.
+ * name-lookup.c (do_nonmember_using_decl): Make sure we have an
+ OVERLOAD before calling OVL_USED. Call diagnose_name_conflict
+ instead of issuing an error without mentioning the conflicting
+ declaration.
+
2013-07-31 Paolo Carlini <paolo.carlini@oracle.com>
* parser.c (cp_parser_sizeof_pack): Check cp_parser_identifier
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 200e78a..859f805 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -346,7 +346,7 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
/* If set, this was imported in a using declaration.
This is not to confuse with being used somewhere, which
is not important for this node. */
-#define OVL_USED(NODE) TREE_USED (NODE)
+#define OVL_USED(NODE) TREE_USED (OVERLOAD_CHECK (NODE))
/* If set, this OVERLOAD was created for argument-dependent lookup
and can be freed afterward. */
#define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 2b1f9fb..0fe0246 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -2316,8 +2316,7 @@ push_overloaded_decl_1 (tree decl, int flags, bool is_friend)
&& compparms (TYPE_ARG_TYPES (TREE_TYPE (fn)),
TYPE_ARG_TYPES (TREE_TYPE (decl)))
&& ! decls_match (fn, decl))
- error ("%q#D conflicts with previous using declaration %q#D",
- decl, fn);
+ diagnose_name_conflict (decl, fn);
dup = duplicate_decls (decl, fn, is_friend);
/* If DECL was a redeclaration of FN -- even an invalid
@@ -2549,7 +2548,7 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype,
if (new_fn == old_fn)
/* The function already exists in the current namespace. */
break;
- else if (OVL_USED (tmp1))
+ else if (TREE_CODE (tmp1) == OVERLOAD && OVL_USED (tmp1))
continue; /* this is a using decl */
else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
@@ -2564,7 +2563,7 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype,
break;
else
{
- error ("%qD is already declared in this scope", name);
+ diagnose_name_conflict (new_fn, old_fn);
break;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 61b8ee6..c8fdfa4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2013-08-01 Fabien Chêne <fabien@gcc.gnu.org>
+ Peter Bergner <bergner@vnet.ibm.com>
+
+ PR c++/54537
+ * g++.dg/overload/using3.C: New.
+ * g++.dg/overload/using2.C: Adjust.
+ * g++.dg/lookup/using9.C: Likewise.
+
2013-08-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* gcc.target/arm/pr46972-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/lookup/using9.C b/gcc/testsuite/g++.dg/lookup/using9.C
index 32abb53..fd3e788 100644
--- a/gcc/testsuite/g++.dg/lookup/using9.C
+++ b/gcc/testsuite/g++.dg/lookup/using9.C
@@ -21,11 +21,11 @@ void h()
f('h');
f(1); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
- void f(int); // { dg-error "previous using declaration" }
+ void f(int); // { dg-error "previous declaration" }
}
void m()
{
void f(int);
- using B::f; // { dg-error "already declared" }
+ using B::f; // { dg-error "previous declaration" }
}
diff --git a/gcc/testsuite/g++.dg/overload/using2.C b/gcc/testsuite/g++.dg/overload/using2.C
index 514d83f..d182454 100644
--- a/gcc/testsuite/g++.dg/overload/using2.C
+++ b/gcc/testsuite/g++.dg/overload/using2.C
@@ -45,7 +45,7 @@ using std::C1;
extern "C" void exit (int) throw ();
extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc));
- void abort (void) throw ();
+ void abort (void) throw (); // { dg-message "previous" }
void _exit (int) throw (); // { dg-error "conflicts" "conflicts" }
// { dg-message "void _exit" "_exit" { target *-*-* } 49 }
@@ -54,14 +54,14 @@ using std::C1;
// { dg-message "void C1" "C1" { target *-*-* } 53 }
extern "C" void c2 (void) throw ();
- void C2 (void) throw ();
+ void C2 (void) throw (); // { dg-message "previous" }
int C3 (int) throw ();
using std::malloc;
-using std::abort; // { dg-error "already declared" }
+using std::abort; // { dg-error "conflicts" }
using std::c2;
-using std::C2; // { dg-error "already declared" }
+using std::C2; // { dg-error "conflicts" }
using std::c3; using other::c3;
using std::C3; using other::C3;
diff --git a/gcc/testsuite/g++.dg/overload/using3.C b/gcc/testsuite/g++.dg/overload/using3.C
new file mode 100644
index 0000000..38344e4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/using3.C
@@ -0,0 +1,16 @@
+// { dg-do compile }
+
+namespace a
+{
+ void f(int);
+}
+
+namespace b
+{
+ void f(int); // { dg-message "previous" }
+ void g()
+ {
+ f (3);
+ }
+ using a::f; // { dg-error "conflicts" }
+}