Commit b726f5e6 by Andrew Pinski Committed by Jakub Jelinek

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
parent d67a3e2a
2009-01-10 Andrew Pinski <pinskia@gmail.com> 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 PR c++/36695
* typeck2.c (build_functional_cast): Check for reference type and NULL * typeck2.c (build_functional_cast): Check for reference type and NULL
PARMS. PARMS.
......
...@@ -6026,7 +6026,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, ...@@ -6026,7 +6026,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
} }
/* Allow array assignment in compiler-generated code. */ /* 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. /* This routine is used for both initialization and assignment.
Make sure the diagnostic message differentiates the context. */ Make sure the diagnostic message differentiates the context. */
......
2009-01-10 Andrew Pinski <pinskia@gmail.com> 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 PR c++/36695
* g++.dg/ext/complex4.C: New test. * g++.dg/ext/complex4.C: New test.
* g++.dg/ext/complex5.C: New test. * g++.dg/ext/complex5.C: New test.
......
// { 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 "" }
// { 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment