public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/44703 (initializer_list typedef)
@ 2010-07-06 19:22 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2010-07-06 19:22 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 122 bytes --]

Need to look through typedefs if we're doing matching on names...

Tested x86_64-pc-linux-gnu, applying to trunk and 4.5.

[-- Attachment #2: 44703.patch --]
[-- Type: text/x-patch, Size: 1148 bytes --]

commit f7a5840c46397ad2e75b9f3a47219d697a75bccf
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Jul 4 09:57:42 2010 -0400

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

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c4f3e95..0bf7b8e 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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);
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist41.C b/gcc/testsuite/g++.dg/cpp0x/initlist41.C
new file mode 100644
index 0000000..b538548
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist41.C
@@ -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}) ;
+}
+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-06 19:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-06 19:22 C++ PATCH for c++/44703 (initializer_list typedef) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).