re PR c++/44703 ([C++0x] List initialization fail if parameter is typedef name for the std::initializer_list)

PR c++/44703
	* call.c (is_std_init_list): Look through typedefs.

From-SVN: r161880
This commit is contained in:
Jason Merrill 2010-07-06 15:23:01 -04:00 committed by Jason Merrill
parent 627bc93888
commit 0060a10ae8
4 changed files with 24 additions and 0 deletions

View File

@ -1,5 +1,8 @@
2010-07-06 Jason Merrill <jason@redhat.com>
PR c++/44703
* call.c (is_std_init_list): Look through typedefs.
PR c++/44778
* init.c (build_offset_ref): If scope isn't dependent,
don't exit early. Look at TYPE_MAIN_VARIANT.

View File

@ -7953,6 +7953,10 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup,
bool
is_std_init_list (tree type)
{
/* Look through typedefs. */
if (!TYPE_P (type))
return false;
type = TYPE_MAIN_VARIANT (type);
return (CLASS_TYPE_P (type)
&& CP_TYPE_CONTEXT (type) == std_node
&& strcmp (TYPE_NAME_STRING (type), "initializer_list") == 0);

View File

@ -1,5 +1,8 @@
2010-07-06 Jason Merrill <jason@redhat.com>
PR c++/44703
* g++.dg/cpp0x/initlist41.C: New.
PR c++/44778
* g++.dg/template/ptrmem22.C: New.

View File

@ -0,0 +1,14 @@
// PR c++/44703
// { dg-options -std=c++0x }
#include <initializer_list>
typedef std::initializer_list<int> type ;
void f(type) {}
int main()
{
// error: could not convert '{1, 2, 3}' to 'type'
f({1,2,3}) ;
}