aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-03-02 02:06:18 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-03-02 02:06:18 +0000
commit676e33ca810aa9f33fd233c75d845638e4755c0d (patch)
treef8b065afcbf7bbac4005023631dc51179db6ee71 /gcc
parent738ed9776c49223ef88f6fe43b7fac990f9f2682 (diff)
downloadgcc-676e33ca810aa9f33fd233c75d845638e4755c0d.zip
gcc-676e33ca810aa9f33fd233c75d845638e4755c0d.tar.gz
gcc-676e33ca810aa9f33fd233c75d845638e4755c0d.tar.bz2
re PR c++/14360 (Overeager argument dependent name lookup)
PR c++/14360 * parser.c (cp_parser_postfix_expression): Do not perform Koenig lookup if ordinary name-lookup finds a non-function. * pt.c (tsubst_copy_and_build): Likewise. PR c++/14361 * parser.c (cp_parser_late_parsing_default_args): Check that there are no extra tokens after the end of the default-argument expression. PR c++/14360 * g++.old-deja/g++.ns/koenig5.C: Remove some error markers. PR c++/14361 * g++.dg/parse/defarg7.C: New test. PR c++/14359 * g++.dg/template/friend26.C: New test. From-SVN: r78739
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/parser.c10
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/g++.dg/parse/defarg7.C5
-rw-r--r--gcc/testsuite/g++.dg/template/friend26.C15
-rw-r--r--gcc/testsuite/g++.old-deja/g++.ns/koenig5.C8
7 files changed, 61 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 02b99e4..21b0172 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -5,6 +5,18 @@
2004-03-01 Mark Mitchell <mark@codesourcery.com>
+ PR c++/14360
+ * parser.c (cp_parser_postfix_expression): Do not perform Koenig
+ lookup if ordinary name-lookup finds a non-function.
+ * pt.c (tsubst_copy_and_build): Likewise.
+
+ PR c++/14361
+ * parser.c (cp_parser_late_parsing_default_args): Check that there
+ are no extra tokens after the end of the default-argument
+ expression.
+
+2004-03-01 Mark Mitchell <mark@codesourcery.com>
+
PR c++/14324
* lex.c (retrofit_lang_decl): Treat entities with no linkage as
having C++ linkage for name-mangling purposes.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 77b5795..9184f0e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -3810,9 +3810,11 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
koenig_p = false;
if (idk == CP_ID_KIND_UNQUALIFIED)
{
+ /* We do not perform argument-dependent lookup if
+ normal lookup finds a non-function, in accordance
+ with the expected resolution of DR 218. */
if (args
&& (is_overloaded_fn (postfix_expression)
- || DECL_P (postfix_expression)
|| TREE_CODE (postfix_expression) == IDENTIFIER_NODE))
{
koenig_p = true;
@@ -14757,6 +14759,12 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
if (DECL_CLASS_SCOPE_P (fn))
pop_nested_class ();
+ /* If the token stream has not been completely used up, then
+ there was extra junk after the end of the default
+ argument. */
+ if (!cp_lexer_next_token_is (parser->lexer, CPP_EOF))
+ cp_parser_error (parser, "expected `,'");
+
/* Restore saved state. */
parser->lexer = saved_lexer;
parser->local_variables_forbidden_p = saved_local_variables_forbidden_p;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 20056eb..8f9a7bd 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8361,10 +8361,12 @@ tsubst_copy_and_build (tree t,
}
call_args = RECUR (TREE_OPERAND (t, 1));
-
+
+ /* We do not perform argument-dependent lookup if normal
+ lookup finds a non-function, in accordance with the
+ expected resolution of DR 218. */
if (koenig_p
&& (is_overloaded_fn (function)
- || DECL_P (function)
|| TREE_CODE (function) == IDENTIFIER_NODE))
function = perform_koenig_lookup (function, call_args);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 459ff66..b2df61f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,16 @@
2004-03-01 Mark Mitchell <mark@codesourcery.com>
+ PR c++/14360
+ * g++.old-deja/g++.ns/koenig5.C: Remove some error markers.
+
+ PR c++/14361
+ * g++.dg/parse/defarg7.C: New test.
+
+ PR c++/14359
+ * g++.dg/template/friend26.C: New test.
+
+2004-03-01 Mark Mitchell <mark@codesourcery.com>
+
PR c++/14324
* g++.dg/abi/mangle21.C: New test.
diff --git a/gcc/testsuite/g++.dg/parse/defarg7.C b/gcc/testsuite/g++.dg/parse/defarg7.C
new file mode 100644
index 0000000..c1f75ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/defarg7.C
@@ -0,0 +1,5 @@
+// PR c++/14361
+
+class A {
+ A ( int n=0 int n ); // { dg-error "" }
+};
diff --git a/gcc/testsuite/g++.dg/template/friend26.C b/gcc/testsuite/g++.dg/template/friend26.C
new file mode 100644
index 0000000..3cf659d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend26.C
@@ -0,0 +1,15 @@
+// PR c++/14359
+
+template<typename> struct A {};
+
+template<typename> struct B
+{
+ template<typename T> friend void foo(const A<T>& a, const B&) { a; }
+};
+
+void bar()
+{
+ A<void> a;
+ B<void> b;
+ foo(a,b);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig5.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig5.C
index 84af9f1..d84fc8d 100644
--- a/gcc/testsuite/g++.old-deja/g++.ns/koenig5.C
+++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig5.C
@@ -1,16 +1,18 @@
// { dg-do assemble }
// To find function pointers in Koenig lookup is ok as long as we only find one.
namespace A{
- void foo(); // { dg-error "" }
+ void foo();
struct X{};
void (*bar)(X*)=0;
}
using A::X;
-void (*foo)(X*)=0; // { dg-error "" }
+void (*foo)(X*)=0;
void g()
{
- foo(new X); // { dg-error "" } both objects and functions found
+ foo(new X); // ok -- DR 218 says that we find the global
+ // foo variable first, and therefore do not
+ // perform argument-dependent lookup.
bar(new X); // ok
}