re PR c++/14002 (Friend declaration with template-id causes confusion of function...
authorMark Mitchell <mark@codesourcery.com>
Tue, 3 Feb 2004 17:59:58 +0000 (17:59 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 3 Feb 2004 17:59:58 +0000 (17:59 +0000)
PR c++/14002
* semantics.c (finish_id_expression): Do not return an
IDENTIFIER_NODE when lookup finds a PARM_DECL.

PR c++/14002
* g++.dg/parse/template13.C: New test.

From-SVN: r77183

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/error13.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/template13.C [new file with mode: 0644]

index 221fbe6..a4c9c81 100644 (file)
@@ -1,5 +1,11 @@
 2004-02-03  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/14002
+       * semantics.c (finish_id_expression): Do not return an
+       IDENTIFIER_NODE when lookup finds a PARM_DECL.
+
+2004-02-03  Mark Mitchell  <mark@codesourcery.com>
+
        PR c++/13978
        * pt.c (build_non_dependent_expr): Do not build
        NON_DEPENDENT_EXPRs for FUNCTION_DECLs or TEMPLATE_DECLs.
index 5b1b1ef..511c7bc 100644 (file)
@@ -2527,7 +2527,8 @@ finish_id_expression (tree id_expression,
          /* If we found a variable, then name lookup during the
             instantiation will always resolve to the same VAR_DECL
             (or an instantiation thereof).  */
-         if (TREE_CODE (decl) == VAR_DECL)
+         if (TREE_CODE (decl) == VAR_DECL
+             || TREE_CODE (decl) == PARM_DECL)
            return decl;
          return id_expression;
        }
index a746adb..b08666a 100644 (file)
@@ -1,5 +1,10 @@
 2004-02-03  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/14002
+       * g++.dg/parse/template13.C: New test.
+
+2004-02-03  Mark Mitchell  <mark@codesourcery.com>
+
        PR c++/13978
        * g++.dg/template/koenig4.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/parse/error13.C b/gcc/testsuite/g++.dg/parse/error13.C
new file mode 100644 (file)
index 0000000..15642e3
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/13975
+
+public: // { dg-error "" }
+
+int i;
+
+protected: // { dg-error "" }
+
+int j;
+
+private: // { dg-error "" }
+
+int k;
diff --git a/gcc/testsuite/g++.dg/parse/template13.C b/gcc/testsuite/g++.dg/parse/template13.C
new file mode 100644 (file)
index 0000000..b1c0369
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/14002
+
+template <typename T> void foo (T x) { x; }
+
+void bar() { foo(0); }
+
+struct A
+{
+  friend void foo<int> (int);
+};