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
This commit is contained in:
Jakub Jelinek 2008-09-17 18:07:08 +02:00 committed by Jakub Jelinek
parent 1b829d45a8
commit 8aff539b68
4 changed files with 21 additions and 2 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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,

View File

@ -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" }
}