]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/42687 (The prevention of ADL with the help of parentheses doesn't work)
authorJason Merrill <jason@redhat.com>
Wed, 27 Apr 2011 05:20:33 +0000 (01:20 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 27 Apr 2011 05:20:33 +0000 (01:20 -0400)
PR c++/42687
* parser.c (cp_parser_primary_expression): Set *idk to
CP_ID_KIND_NONE for a parenthesized identifier.

From-SVN: r173009

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/koenig13.C [new file with mode: 0644]

index 0ae5b3ca2c5f7e896f853cbbb6cb296b677e69da..ffc7e8c4c33ce5fe95d6fadb0452b3b5bb70faba 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/42687
+       * parser.c (cp_parser_primary_expression): Set *idk to
+       CP_ID_KIND_NONE for a parenthesized identifier.
+
 2011-04-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/48594
index 64e7329641a29313015d2b70bed16e76c09ebbd8..f219b1b5926c1491ea2f3ac8434de25eaa839915 100644 (file)
@@ -3274,6 +3274,12 @@ cp_parser_primary_expression (cp_parser *parser,
               `&A::B' might be a pointer-to-member, but `&(A::B)' is
               not.  */
            finish_parenthesized_expr (expr);
+           /* DR 705: Wrapping an unqualified name in parentheses
+              suppresses arg-dependent lookup.  We want to pass back
+              CP_ID_KIND_QUALIFIED for suppressing vtable lookup
+              (c++/37862), but none of the others.  */
+           if (*idk != CP_ID_KIND_QUALIFIED)
+             *idk = CP_ID_KIND_NONE;
          }
        /* The `>' token might be the end of a template-id or
           template-parameter-list now.  */
index 223467dd44ba7268cc74629f0e80b34ab2b0713b..e4be028242726ff3f6df078cfe018f7da1b02894 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-26  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/lookup/koenig13.C: New.
+
 2011-04-20  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/template/operator11.C: New.
diff --git a/gcc/testsuite/g++.dg/lookup/koenig13.C b/gcc/testsuite/g++.dg/lookup/koenig13.C
new file mode 100644 (file)
index 0000000..625a181
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/42687
+// DR 705
+
+namespace N
+{
+    struct S { };
+    void f(const S &) { }
+}
+
+void f(const N::S &) { }
+
+int main()
+{
+    N::S v;
+    (f)(v); // no ambiguity: ADL is prevented with (), only ::f is considered
+}