From: jakub Date: Sat, 10 Jan 2009 11:49:04 +0000 (+0000) Subject: PR c++/38648 X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=f3056c5903878061b38250d1ac4944d08624d776;p=pf3gnuchains%2Fgcc-fork.git 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143245 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ad9b8581cce..b1542f072dd 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 577e026256f..3c7787c675c 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 2180b46a6b1..18e734ea91b 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 00000000000..3901427f439 --- /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 00000000000..252fa70364a --- /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; +} +