re PR c++/58705 ([c++11] ICE with invalid initializer for _Complex variable)
authorMarek Polacek <polacek@redhat.com>
Thu, 24 Oct 2013 13:54:00 +0000 (13:54 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 24 Oct 2013 13:54:00 +0000 (13:54 +0000)
PR c++/58705
cp/
* typeck2.c (check_narrowing): Don't check narrowing when the scalar
initializer is empty.
testsuite/
* g++.dg/parse/pr58705.C: New test.

From-SVN: r204014

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/pr58705.C [new file with mode: 0644]

index 123200bd929989c4249f1c9c888e77081b49bbb4..5fa01fe1a96a504cd0f23820951569f269b1f610 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-24  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/58705
+       * typeck2.c (check_narrowing): Don't check narrowing when the scalar
+       initializer is empty.
+
 2013-10-23  Jason Merrill  <jason@redhat.com>
 
        LWG 2165
index 4b71a76f4d28aa74f375aa6ad0209758a71ea015..d6ff3caf00dcee1f7ddc62fea6428f7b6b8680df 100644 (file)
@@ -834,7 +834,8 @@ check_narrowing (tree type, tree init)
       && TREE_CODE (type) == COMPLEX_TYPE)
     {
       tree elttype = TREE_TYPE (type);
-      check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value);
+      if (CONSTRUCTOR_NELTS (init) > 0)
+        check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value);
       if (CONSTRUCTOR_NELTS (init) > 1)
        check_narrowing (elttype, CONSTRUCTOR_ELT (init, 1)->value);
       return;
index d68f3846cac5384e5f3d418ad8009defc3e8778e..b77200aa5dab1ad3ef451b2110550a9102746b41 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-24  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/58705
+       * g++.dg/parse/pr58705.C: New test.
+
 2013-10-24  Marek Polacek  <polacek@redhat.com>
 
        * gcc.dg/c11-align-5.c: Add more testing.
diff --git a/gcc/testsuite/g++.dg/parse/pr58705.C b/gcc/testsuite/g++.dg/parse/pr58705.C
new file mode 100644 (file)
index 0000000..de2b396
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/58705
+// { dg-do compile }
+// { dg-options "-Wnarrowing" }
+
+_Complex float f = {{}};