aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2017-02-21 15:51:03 -0500
committerJason Merrill <jason@gcc.gnu.org>2017-02-21 15:51:03 -0500
commit626aeaa7acf6b73d0d4df5f628cb127bd9848cba (patch)
tree765061121d3dc24ba7155a22889049683b9ce6c6 /gcc
parent46b48ef565a731734522304b95b893ea07ac7ca0 (diff)
downloadgcc-626aeaa7acf6b73d0d4df5f628cb127bd9848cba.zip
gcc-626aeaa7acf6b73d0d4df5f628cb127bd9848cba.tar.gz
gcc-626aeaa7acf6b73d0d4df5f628cb127bd9848cba.tar.bz2
PR c++/50308 - wrong deprecated warning with ADL
PR c++/17729 - duplicate deprecated warning * semantics.c (finish_id_expression): Only call mark_used on a function if we aren't building a call. From-SVN: r245643
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/semantics.c10
-rw-r--r--gcc/testsuite/c-c++-common/pr69558.c2
-rw-r--r--gcc/testsuite/g++.dg/warn/deprecated-12.C20
4 files changed, 35 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 13d7d33..42c6a52 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2017-02-21 Jason Merrill <jason@redhat.com>
+ PR c++/50308 - wrong deprecated warning with ADL
+ PR c++/17729 - duplicate deprecated warning
+ * semantics.c (finish_id_expression): Only call mark_used on a
+ function if we aren't building a call.
+
PR c++/41727 - ICE with partial spec of partial instantiation
* pt.c (process_partial_specialization): For now, don't check more
specialized if there is more than one level of args.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6a47476..6ba7c13 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3743,7 +3743,15 @@ finish_id_expression (tree id_expression,
if (TREE_CODE (first_fn) == TEMPLATE_DECL)
first_fn = DECL_TEMPLATE_RESULT (first_fn);
- if (!really_overloaded_fn (decl)
+ /* [basic.def.odr]: "A function whose name appears as a
+ potentially-evaluated expression is odr-used if it is the unique
+ lookup result".
+
+ But only mark it if it's a complete postfix-expression; in a call,
+ ADL might select a different function, and we'll call mark_used in
+ build_over_call. */
+ if (done
+ && !really_overloaded_fn (decl)
&& !mark_used (first_fn))
return error_mark_node;
diff --git a/gcc/testsuite/c-c++-common/pr69558.c b/gcc/testsuite/c-c++-common/pr69558.c
index 102d72c..4c6d498 100644
--- a/gcc/testsuite/c-c++-common/pr69558.c
+++ b/gcc/testsuite/c-c++-common/pr69558.c
@@ -16,4 +16,4 @@
__attribute__((deprecated)) void foo (void); /* { dg-bogus "declared here" "" { xfail { c++ } } } */
-C (foo) /* { dg-bogus "is deprecated" "" { xfail { c++ } } } */
+C (foo) /* { dg-bogus "is deprecated" } */
diff --git a/gcc/testsuite/g++.dg/warn/deprecated-12.C b/gcc/testsuite/g++.dg/warn/deprecated-12.C
new file mode 100644
index 0000000..df5c76f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/deprecated-12.C
@@ -0,0 +1,20 @@
+// PR c++/50308
+
+void A( int ) __attribute__((deprecated));
+
+namespace B {
+
+ struct C {};
+
+ void A(C) {}
+
+}
+
+int main ()
+{
+ B::C x;
+
+ // ADL correctly identifies the non-deprecated B::A, but a warning about the
+ // global A is generated anyway
+ A( x ); // { dg-bogus "deprecated" }
+}