From 320a9762ee8a82e96c00da7a566df288e4c93266 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 24 Oct 2013 13:54:00 +0000 Subject: [PATCH] re PR c++/58705 ([c++11] ICE with invalid initializer for _Complex variable) 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 | 6 ++++++ gcc/cp/typeck2.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/pr58705.C | 5 +++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/parse/pr58705.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 123200bd929..5fa01fe1a96 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-10-24 Marek Polacek + + PR c++/58705 + * typeck2.c (check_narrowing): Don't check narrowing when the scalar + initializer is empty. + 2013-10-23 Jason Merrill LWG 2165 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 4b71a76f4d2..d6ff3caf00d 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d68f3846cac..b77200aa5da 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2013-10-24 Marek Polacek + PR c++/58705 + * g++.dg/parse/pr58705.C: New test. + +2013-10-24 Marek Polacek + * gcc.dg/c11-align-5.c: Add more testing. 2013-10-23 Pat Haugen diff --git a/gcc/testsuite/g++.dg/parse/pr58705.C b/gcc/testsuite/g++.dg/parse/pr58705.C new file mode 100644 index 00000000000..de2b396a5e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr58705.C @@ -0,0 +1,5 @@ +// PR c++/58705 +// { dg-do compile } +// { dg-options "-Wnarrowing" } + +_Complex float f = {{}}; -- 2.11.4.GIT