mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 15:11:08 +08:00
re PR c++/27961 (ICE on invalid template declaration)
PR c++/27961 * decl.c (start_decl): Return error_mark_node if a function is initialized like a variable. (check_var_type): If a variable of field is declared void, set the type to error_mark_node. (grokdeclarator): Check the return type of check_var_type. * class.c (finish_struct_1): Robustify. * g++.dg/template/crash60.C: New test. * g++.dg/other/large-size-array.C: Adjust error markers. * g++.dg/parse/crash27.C: Likewise. * g++.dg/template/crash1.C: Likewise. From-SVN: r117671
This commit is contained in:
parent
dc0aeb6069
commit
650fcd0729
@ -1,3 +1,13 @@
|
||||
2006-10-12 Lee Millward <lee.millward@codesourcery.com>
|
||||
|
||||
PR c++/27961
|
||||
* decl.c (start_decl): Return error_mark_node if a
|
||||
function is initialized like a variable.
|
||||
(check_var_type): If a variable of field is declared void,
|
||||
set the type to error_mark_node.
|
||||
(grokdeclarator): Check the return type of check_var_type.
|
||||
* class.c (finish_struct_1): Robustify.
|
||||
|
||||
2006-10-11 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/29175
|
||||
|
@ -5062,6 +5062,7 @@ finish_struct_1 (tree t)
|
||||
working on. */
|
||||
for (x = TYPE_FIELDS (t); x; x = TREE_CHAIN (x))
|
||||
if (TREE_CODE (x) == VAR_DECL && TREE_STATIC (x)
|
||||
&& TREE_TYPE (x) != error_mark_node
|
||||
&& same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (x)), t))
|
||||
DECL_MODE (x) = TYPE_MODE (t);
|
||||
|
||||
|
@ -3854,8 +3854,7 @@ start_decl (const cp_declarator *declarator,
|
||||
|
||||
case FUNCTION_DECL:
|
||||
error ("function %q#D is initialized like a variable", decl);
|
||||
initialized = 0;
|
||||
break;
|
||||
return error_mark_node;
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -6810,7 +6809,7 @@ check_var_type (tree identifier, tree type)
|
||||
}
|
||||
else
|
||||
error ("variable or field declared void");
|
||||
type = integer_type_node;
|
||||
type = error_mark_node;
|
||||
}
|
||||
|
||||
return type;
|
||||
@ -8178,7 +8177,11 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
/* We don't check parameter types here because we can emit a better
|
||||
error message later. */
|
||||
if (decl_context != PARM)
|
||||
type = check_var_type (unqualified_id, type);
|
||||
{
|
||||
type = check_var_type (unqualified_id, type);
|
||||
if (type == error_mark_node)
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
/* Now create the decl, which may be a VAR_DECL, a PARM_DECL
|
||||
or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE. */
|
||||
|
@ -1,3 +1,11 @@
|
||||
2006-10-12 Lee Millward <lee.millward@codesourcery.com>
|
||||
|
||||
PR c++/27961
|
||||
* g++.dg/template/crash60.C: New test.
|
||||
* g++.dg/other/large-size-array.C: Adjust error markers.
|
||||
* g++.dg/parse/crash27.C: Likewise.
|
||||
* g++.dg/template/crash1.C: Likewise.
|
||||
|
||||
2006-10-12 Steve Ellcey <sje@cup.hp.com>
|
||||
|
||||
PR testsuite/29093
|
||||
|
@ -17,7 +17,7 @@ int
|
||||
main (void)
|
||||
{
|
||||
int a[DIM][DIM]; /* { dg-error "size of array 'a' is too large" } */
|
||||
return sub (&a[0][0]);
|
||||
return sub (&a[0][0]); /* { dg-error "declared" } */
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,4 +6,3 @@ void Dispatcher()
|
||||
/* { dg-error "expected type" "expected 1" { target *-*-* } 4 } */
|
||||
/* { dg-error "expected `,' before" "expected 2" { target *-*-* } 4 } */
|
||||
/* { dg-error "expected `\\\)" "expected 3" { target *-*-* } 4 } */
|
||||
/* { dg-error "expected ',' or" "expected 4" { target *-*-* } 4 } */
|
||||
|
@ -13,5 +13,5 @@ class S
|
||||
|
||||
template <class I>
|
||||
void S::Foo(int (*f)(TYPO&o) ) // { dg-error "Foo|f|TYPO|o" }
|
||||
{ // { dg-error "expected `;'" }
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user