This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFH / Patch] PR 51222


Hi,

On 05/02/2012 03:47 AM, Jason Merrill wrote:
On 05/01/2012 08:14 PM, Paolo Carlini wrote:
I think we need to handle FIELD_DECL, too.
Are there hopes that handling FIELD_DECL like FUNCTION_DECL and VAR_DECL
(besides the DECL_LANG_SPECIFIC check) would work?
I would think so.
Ok, if we want it, I adjusted the code, see attached.
A data point I can give you, I put a gcc_assert (TREE_CODE (t) != FIELD_DECL) in the default case of the walk_template_parms_r switch, and it never triggers for the whole testsuite.

With your patch, what happens if you have a member access like


template <class T>
struct A
{
  T t;
  auto f(A a) -> decltype (sizeof (a.t)) { }
};

I would expect that to hit the FIELD_DECL case.
Well, not really. The first time walk_template_parms_r is called, t is a SIZEOF_EXPR which remains unhandled, the function returns NULL_TREE. The second time, t is a COMPONENT_REF, thus !TYPE_P (t) is true, TREE_TYPE is NULL, the function immediately returns error_mark_node and the iteration ends (with the correct result that the expression is instantiation-dependent).

Does it make sense?

Anyway, the attached appear to also pass the testsuite, I could test it more completely tomorrow. If the FIELD_DECL bits seem safe to have... ;)

Thanks,
Paolo.


Attachment: patch_51222_8
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]