re PR c++/50361 ([C++0x] [4.7 Regression] ICE with std::initializer_list and nullptr)
authorJason Merrill <jason@redhat.com>
Thu, 15 Sep 2011 14:33:24 +0000 (10:33 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 15 Sep 2011 14:33:24 +0000 (10:33 -0400)
PR c++/50361
* expr.c (count_type_elements): Handle NULLPTR_TYPE.

From-SVN: r178882

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nullptr23.C [new file with mode: 0644]

index d0b662b..33fbaee 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-15  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50361
+       * expr.c (count_type_elements): Handle NULLPTR_TYPE.
+
 2011-09-15  Jan Hubicka  <jh@suse.cz>
 
        * ipa-inline-analysis.c (add_condition): Add conditions parameter;
index e4bb633..29bf68b 100644 (file)
@@ -5296,6 +5296,7 @@ count_type_elements (const_tree type, bool for_ctor_p)
     case POINTER_TYPE:
     case OFFSET_TYPE:
     case REFERENCE_TYPE:
+    case NULLPTR_TYPE:
       return 1;
 
     case ERROR_MARK:
index 71e748d..0bf6170 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-15  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50361
+       * g++.dg/cpp0x/nullptr23.C: New.
+
 2011-09-15  Ira Rosen  <ira.rosen@linaro.org>
 
        * gcc.dg/vect/bb-slp-25.c: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr23.C b/gcc/testsuite/g++.dg/cpp0x/nullptr23.C
new file mode 100644 (file)
index 0000000..a078269
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/50361
+// { dg-options -std=c++0x }
+
+#include <initializer_list>
+
+struct Foo
+{
+  Foo(std::initializer_list<Foo>) { };
+
+  template<class T> Foo(T t) { T u(t); };
+
+private:
+  union Data
+  {
+    Data() : null(nullptr) {}
+
+    std::nullptr_t null;
+  } u_;
+};
+
+int main()
+{
+  Foo f = { {} };
+}