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:17:20 +0000 (01:17 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 27 Apr 2011 05:17:20 +0000 (01:17 -0400)
PR c++/42687
* parser.c (cp_parser_primary_expression): Set *idk to
CP_ID_KIND_NONE for a parenthesized identifier.

From-SVN: r173007

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

index 2eabf118cb3257c628646b1e1cbb33f041c2a83a..c6e83decff2a95856e101ced725ab98c43f78ef2 100644 (file)
@@ -1,5 +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.
+
        * ptree.c (cxx_print_type) [TYPENAME_TYPE]: Dump fullname.
        (cxx_print_identifier): Correct indentation.
 
index 6da285e83dd30dfc3e4774dcf3728eee54f597e0..68ce052612a2e6e3ff2ae2798e0704c529be26f5 100644 (file)
@@ -3437,6 +3437,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 f95a2113f7a967167ea6f12d640fa837ee98d3a8..f39f7edef7db199b673916d87cbf8e7245873811 100644 (file)
@@ -1,5 +1,7 @@
 2011-04-26  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/lookup/koenig13.C: New.
+
        * g++.dg/cpp0x/initlist48.C: New.
 
 2011-04-25  Jason Merrill  <jason@redhat.com>
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
+}