Commit fb077955 by Jason Merrill Committed by Jason Merrill

re PR c++/41185 (size of array ... has non-integral type ...)

	PR c++/41185
	PR c++/41786
	* parser.c (cp_parser_direct_declarator): Don't allow VLAs in
	function parameter context.  Don't print an error if parsing
	tentatively.

From-SVN: r157838
parent 5847e8da
2010-03-30 Jason Merrill <jason@redhat.com> 2010-03-30 Jason Merrill <jason@redhat.com>
PR c++/41185
PR c++/41786
* parser.c (cp_parser_direct_declarator): Don't allow VLAs in
function parameter context. Don't print an error if parsing
tentatively.
PR c++/43559 PR c++/43559
* pt.c (more_specialized_fn): Don't control cv-qualifier check * pt.c (more_specialized_fn): Don't control cv-qualifier check
with same_type_p. with same_type_p.
......
...@@ -14106,11 +14106,13 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -14106,11 +14106,13 @@ cp_parser_direct_declarator (cp_parser* parser,
bounds = fold_non_dependent_expr (bounds); bounds = fold_non_dependent_expr (bounds);
/* Normally, the array bound must be an integral constant /* Normally, the array bound must be an integral constant
expression. However, as an extension, we allow VLAs expression. However, as an extension, we allow VLAs
in function scopes. */ in function scopes as long as they aren't part of a
else if (!parser->in_function_body) parameter declaration. */
else if (!parser->in_function_body
|| current_binding_level->kind == sk_function_parms)
{ {
error_at (token->location, cp_parser_error (parser,
"array bound is not an integer constant"); "array bound is not an integer constant");
bounds = error_mark_node; bounds = error_mark_node;
} }
else if (processing_template_decl && !error_operand_p (bounds)) else if (processing_template_decl && !error_operand_p (bounds))
......
2010-03-30 Jason Merrill <jason@redhat.com>
PR c++/41786
* g++.dg/parse/ambig5.C: New.
2010-03-30 Jakub Jelinek <jakub@redhat.com> 2010-03-30 Jakub Jelinek <jakub@redhat.com>
PR debug/43593 PR debug/43593
......
// PR c++/41786
struct A { A(int, char const*); };
int main() {
int i = 0, *b = &i;
A a(int(b[i]), "hello");
}
...@@ -2,6 +2,6 @@ int main(int argc, char** argv) { ...@@ -2,6 +2,6 @@ int main(int argc, char** argv) {
int nx = 2; int nx = 2;
void theerror(double a[][nx+1]); // { dg-message "" } void theerror(double a[][nx+1]); // { dg-message "" }
double** a; double** a;
theerror(a); // { dg-error "" } theerror(a);
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment