From: Andrew Pinski Date: Sat, 10 Jan 2009 11:49:04 +0000 (-0800) Subject: re PR c++/38648 (ICE with string literal) X-Git-Tag: releases/gcc-4.4.0~941 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b726f5e6c3c90244570ae64822f06006db966096;p=thirdparty%2Fgcc.git re PR c++/38648 (ICE with string literal) PR c++/38648 * typeck.c (cp_build_modify_expr): Check for NULL current_function_decl. * g++.dg/expr/string-1.C: New test. * g++.dg/expr/string-2.C: New test. From-SVN: r143245 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ad9b8581cce0..b1542f072ddb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2009-01-10 Andrew Pinski + PR c++/38648 + * typeck.c (cp_build_modify_expr): Check for NULL current_function_decl. + PR c++/36695 * typeck2.c (build_functional_cast): Check for reference type and NULL PARMS. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 577e026256fd..3c7787c675cc 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6026,7 +6026,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, } /* Allow array assignment in compiler-generated code. */ - if (! DECL_ARTIFICIAL (current_function_decl)) + if (!current_function_decl || !DECL_ARTIFICIAL (current_function_decl)) { /* This routine is used for both initialization and assignment. Make sure the diagnostic message differentiates the context. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2180b46a6b1a..18e734ea91b7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2009-01-10 Andrew Pinski + PR c++/38648 + * g++.dg/expr/string-1.C: New test. + * g++.dg/expr/string-2.C: New test. + PR c++/36695 * g++.dg/ext/complex4.C: New test. * g++.dg/ext/complex5.C: New test. diff --git a/gcc/testsuite/g++.dg/expr/string-1.C b/gcc/testsuite/g++.dg/expr/string-1.C new file mode 100644 index 000000000000..3901427f439e --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/string-1.C @@ -0,0 +1,10 @@ +// { dg-do compile } +// This testcase used to seg fault (PR c++/38648) + +char a[1]; + +int foo( // { dg-error "extended initializer lists only available" } +{ + a = ""; // { dg-error "" } + return 0; // { dg-error "" } +} // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/expr/string-2.C b/gcc/testsuite/g++.dg/expr/string-2.C new file mode 100644 index 000000000000..252fa70364a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/string-2.C @@ -0,0 +1,10 @@ +// { dg-do compile } +// This testcase used to seg fault (PR c++/38648) + +char a[1]; + +int foo(a = "") // { dg-error "invalid array assignment" } +{ // { dg-error "" } + return 0; +} +