aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-09-17 18:07:08 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2008-09-17 18:07:08 +0200
commit8aff539b6829d3a984615f011851e3cbf6fa7ba8 (patch)
treee19625cd09d95efc3c523d785717dd1dba53c2a4 /gcc
parent1b829d45a824ffabbc1e0cd6b3999d64bd783a17 (diff)
downloadgcc-8aff539b6829d3a984615f011851e3cbf6fa7ba8.zip
gcc-8aff539b6829d3a984615f011851e3cbf6fa7ba8.tar.gz
gcc-8aff539b6829d3a984615f011851e3cbf6fa7ba8.tar.bz2
re PR c++/37552 (ICE with invalid array access)
PR c++/37552 * typeck.c (build_array_ref): Use protected_set_expr_location instead of SET_EXPR_LOCATION when ret might not be an expression. * g++.dg/parse/crash49.C: New test. From-SVN: r140422
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c4
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/parse/crash49.C10
4 files changed, 21 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 903f45c..791808d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/37552
+ * typeck.c (build_array_ref): Use protected_set_expr_location instead
+ of SET_EXPR_LOCATION when ret might not be an expression.
+
2008-09-17 Jan Hubicka <jh@suse.cz>
PR c++/18071
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9de51c5..cfa33ae 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2544,7 +2544,7 @@ build_array_ref (tree array, tree idx, location_t loc)
build_array_ref (TREE_OPERAND (array, 1), idx, loc),
build_array_ref (TREE_OPERAND (array, 2), idx, loc),
tf_warning_or_error);
- SET_EXPR_LOCATION (ret, loc);
+ protected_set_expr_location (ret, loc);
return ret;
default:
@@ -2623,7 +2623,7 @@ build_array_ref (tree array, tree idx, location_t loc)
TREE_THIS_VOLATILE (rval)
|= (CP_TYPE_VOLATILE_P (type) | TREE_THIS_VOLATILE (array));
ret = require_complete_type (fold_if_not_in_template (rval));
- SET_EXPR_LOCATION (ret, loc);
+ protected_set_expr_location (ret, loc);
return ret;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f62304e..9933c79 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2008-09-17 Jakub Jelinek <jakub@redhat.com>
+ PR c++/37552
+ * g++.dg/parse/crash49.C: New test.
+
PR preprocessor/37324
* lib/target-supports.exp
(check_effective_target_wchar_t_char16_t_compatible,
diff --git a/gcc/testsuite/g++.dg/parse/crash49.C b/gcc/testsuite/g++.dg/parse/crash49.C
new file mode 100644
index 0000000..07d7c3b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/crash49.C
@@ -0,0 +1,10 @@
+// PR c++/37552
+// { dg-do compile }
+
+extern struct A a[1]; // { dg-error "forward declaration" }
+
+void
+foo ()
+{
+ a[0]; // { dg-error "invalid use of incomplete type" }
+}