This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: c++/4862 and PRs marked (or not) as parser bugs
- From: "H . J . Lu" <hjl at lucon dot org>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 2 Feb 2002 11:05:16 -0800
- Subject: Re: c++/4862 and PRs marked (or not) as parser bugs
- References: <3C5BC603.2355A224@unitus.it>
On Sat, Feb 02, 2002 at 11:57:07AM +0100, Paolo Carlini wrote:
> Hi,
>
> c++/4862 is about this kind of situation:
>
> ////////////
> class A
> {
> public:
> template<typename T>
> void func() {}
> };
>
> template<typename T>
> void doit()
> {
> A a;
> a.func<T>();
> };
> ////////////
>
> as well known, the current parser must be helped changing line 12 to:
>
> a.template func<T>();
>
> What seems to me strange, is that the *new* parser must *also* be helped like
> this (not EDG front ends). Is this known? Should c++/4862 and, perhaps, similar
> situations, be marked as "New-parser bug" in GNATS?
>
I have sent a testcase long time ago:
http://gcc.gnu.org/ml/gcc-patches/2001-08/msg01378.html
Are they the same thing? Here is a patch I have been using without any
problem. BTW, I have no ideas what I am doing.
H.J.
---
2001-08-26 H.J. Lu (hjl@gnu.org)
* gcc/cp/decl.c (lookup_name_real): Handle prefer_type == 3.
* parse.y (object): Handle LOOKUP_EXPR.
--- gcc/cp/decl.c.template Fri Aug 24 09:06:06 2001
+++ gcc/cp/decl.c Sat Aug 25 16:07:29 2001
@@ -6005,6 +6005,8 @@ lookup_name_real (name, prefer_type, non
else if ((flags & LOOKUP_PREFER_TYPES)
&& qualify_lookup (BINDING_TYPE (t), flags))
binding = BINDING_TYPE (t);
+ else if (prefer_type == 3)
+ binding = BINDING_VALUE (t);
else
binding = NULL_TREE;
--- gcc/cp/parse.y.template Fri Aug 24 00:17:24 2001
+++ gcc/cp/parse.y Sat Aug 25 15:59:57 2001
@@ -1730,11 +1730,65 @@ nodecls:
object:
primary '.'
- { got_object = TREE_TYPE ($$); }
+ {
+ tree name;
+ got_object = TREE_TYPE ($$);
+ name = $$;
+ while (TREE_CODE (name) == ADDR_EXPR
+ || TREE_CODE (name) == INDIRECT_REF)
+ name = TREE_OPERAND (name, 0);
+ if (got_object == NULL_TREE
+ && TREE_CODE (name) == LOOKUP_EXPR)
+ {
+ name = lookup_name (TREE_OPERAND (name, 0), 3);
+ if (name)
+ {
+ got_object = TREE_TYPE (name);
+ if (got_object)
+ {
+ switch (TREE_CODE (got_object))
+ {
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ got_object = TREE_TYPE (got_object);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
| primary POINTSAT
{
+ tree name;
+ name = $$;
+ while (TREE_CODE (name) == ADDR_EXPR
+ || TREE_CODE (name) == INDIRECT_REF)
+ name = TREE_OPERAND (name, 0);
$$ = build_x_arrow ($$);
got_object = TREE_TYPE ($$);
+ if (got_object == NULL_TREE
+ && TREE_CODE (name) == LOOKUP_EXPR)
+ {
+ name = lookup_name (TREE_OPERAND (name, 0), 3);
+ if (name)
+ {
+ got_object = TREE_TYPE (name);
+ if (got_object)
+ {
+ switch (TREE_CODE (got_object))
+ {
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ got_object = TREE_TYPE (got_object);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
}
;