]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38648 (ICE with string literal)
authorAndrew Pinski <pinskia@gmail.com>
Sat, 10 Jan 2009 11:49:04 +0000 (03:49 -0800)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 10 Jan 2009 11:49:04 +0000 (12:49 +0100)
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

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/string-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/expr/string-2.C [new file with mode: 0644]

index ad9b8581cce0d278f936cc63fa0eb41cb6e398e9..b1542f072ddbe8a193a72c2aee079343e315d7c6 100644 (file)
@@ -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.
index 577e026256fd72bfd6b52558df9f3c0ff4cd6167..3c7787c675cc711f24b6f602ebf3177b826668d2 100644 (file)
@@ -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.  */
index 2180b46a6b1a9446d10d011b226edf2dce5f431d..18e734ea91b70d26f8b67cb74e77affeb902206d 100644 (file)
@@ -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 (file)
index 0000000..3901427
--- /dev/null
@@ -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 (file)
index 0000000..252fa70
--- /dev/null
@@ -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;
+}
+