OSDN Git Service

PR c++/42026, DR 239
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Nov 2009 20:58:47 +0000 (20:58 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Nov 2009 20:58:47 +0000 (20:58 +0000)
* parser.c (cp_parser_postfix_expression): A local extern also
prevents arg-dependent lookup.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154686 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 4f0d5b8..a4142a2 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/42026, DR 239
+       * parser.c (cp_parser_postfix_expression): A local extern also
+       prevents arg-dependent lookup.
+
 2009-11-26  Gabriel Dos Reis  <gdr@cs.tamu.edu>
 
        * decl.c (grokdeclarator): Remove period at end of diagnosic message.
index 0b6fa01..cd0382e 100644 (file)
@@ -4844,14 +4844,13 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
                         && is_overloaded_fn (postfix_expression))
                  {
                    tree fn = get_first_fn (postfix_expression);
+                   fn = STRIP_TEMPLATE (fn);
 
-                   if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
-                     fn = OVL_CURRENT (TREE_OPERAND (fn, 0));
-
-                   /* Only do argument dependent lookup if regular
-                      lookup does not find a set of member functions.
-                      [basic.lookup.koenig]/2a  */
-                   if (!DECL_FUNCTION_MEMBER_P (fn))
+                   /* Do not do argument dependent lookup if regular
+                      lookup finds a member function or a block-scope
+                      function declaration.  [basic.lookup.argdep]/3  */
+                   if (!DECL_FUNCTION_MEMBER_P (fn)
+                       && !DECL_LOCAL_FUNCTION_P (fn))
                      {
                        koenig_p = true;
                        if (!any_type_dependent_arguments_p (args))
index ca2cd0e..8d1dbc8 100644 (file)
@@ -1,5 +1,8 @@
 2009-11-26  Jason Merrill  <jason@redhat.com>
 
+       PR c++/42026, DR 239
+       * g++.dg/lookup/koenig8.C: New.
+
        PR c++/10690
        * g++.dg/template/explicit-args2.C: Add typeid cases.
 
diff --git a/gcc/testsuite/g++.dg/lookup/koenig8.C b/gcc/testsuite/g++.dg/lookup/koenig8.C
new file mode 100644 (file)
index 0000000..b555855
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/42026, DR 239
+// The local extern declaration prevents arg-dependent lookup.
+// { dg-do link }
+
+namespace NS {
+  class T { };
+  void g(T, int);
+}
+NS::T parm;
+void g(NS::T, float) { }
+int main() {
+  extern void g(NS::T, float);
+  g(parm, 1);
+}