Commit 21920fd1 by Jason Merrill Committed by Jason Merrill

re PR c++/42277 (decltype error in template)

	PR c++/42277
	* semantics.c (finish_decltype_type): Don't assume that op1 of a
	COMPONENT_REF is always the field.
	* g++.dg/cpp0x/decltype20.C: New.

From-SVN: r155002
parent 2f2d7386
2009-12-04 Jason Merrill <jason@redhat.com>
PR c++/42277
* semantics.c (finish_decltype_type): Defer handling of decltype
of a non-dependent COMPONENT_REF in a template.
2009-12-04 Dodji Seketeli <dodji@redhat.com> 2009-12-04 Dodji Seketeli <dodji@redhat.com>
PR c++/42218 PR c++/42218
......
...@@ -4777,7 +4777,13 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) ...@@ -4777,7 +4777,13 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p)
return error_mark_node; return error_mark_node;
} }
if (type_dependent_expression_p (expr)) if (type_dependent_expression_p (expr)
/* In a template, a COMPONENT_REF has an IDENTIFIER_NODE for op1 even
if it isn't dependent, so that we can check access control at
instantiation time, so defer the decltype as well (PR 42277). */
|| (id_expression_or_member_access_p
&& processing_template_decl
&& TREE_CODE (expr) == COMPONENT_REF))
{ {
if (id_expression_or_member_access_p) if (id_expression_or_member_access_p)
{ {
......
2009-12-04 Jason Merrill <jason@redhat.com>
PR c++/42277
* g++.dg/cpp0x/decltype20.C: New.
2009-12-04 David Daney <ddaney@caviumnetworks.com> 2009-12-04 David Daney <ddaney@caviumnetworks.com>
PR rtl-optimization/42164 PR rtl-optimization/42164
......
// PR c++/42277
// { dg-options -std=c++0x }
struct S { int s; };
template <int N>
void foo ()
{
S s;
decltype (s.s) i;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment