OSDN Git Service

PR c++/38648
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Jan 2009 11:49:04 +0000 (11:49 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Jan 2009 11:49:04 +0000 (11:49 +0000)
* 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

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 ad9b858..b1542f0 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 577e026..3c7787c 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 2180b46..18e734e 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;
+}
+