diff options
author | Andrew Pinski <pinskia@gmail.com> | 2009-01-10 03:49:04 -0800 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2009-01-10 12:49:04 +0100 |
commit | b726f5e6c3c90244570ae64822f06006db966096 (patch) | |
tree | 5ec0b33bb25bc29454382b2d843ff3ff1fbc955e | |
parent | d67a3e2a7f780fd0d703944751549944860cd134 (diff) | |
download | gcc-b726f5e6c3c90244570ae64822f06006db966096.zip gcc-b726f5e6c3c90244570ae64822f06006db966096.tar.gz gcc-b726f5e6c3c90244570ae64822f06006db966096.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/string-1.C | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/string-2.C | 10 |
5 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ad9b858..b1542f0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2009-01-10 Andrew Pinski <pinskia@gmail.com> + 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 577e026..3c7787c 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 2180b46..18e734e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2009-01-10 Andrew Pinski <pinskia@gmail.com> + 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 0000000..3901427 --- /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 0000000..252fa70 --- /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; +} + |