aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-03-30 21:19:23 +0000
committerJason Merrill <jason@redhat.com>2010-03-30 21:19:23 +0000
commitdfabbebf86f170b207711e37e33be823dc8215b0 (patch)
tree22d722eb9df61b144415c5522e89d9e303d6247a
parent3b02840b58675a013bae7840b7ed9bb89dc1ef4b (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@157838 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/ambig5.C7
-rw-r--r--gcc/testsuite/g++.dg/parse/varmod1.C2
5 files changed, 25 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index eb42b0be8c9..2f6ae04daf9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
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
* pt.c (more_specialized_fn): Don't control cv-qualifier check
with same_type_p.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 693d6cd692e..6b119b6907e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14106,11 +14106,13 @@ cp_parser_direct_declarator (cp_parser* parser,
bounds = fold_non_dependent_expr (bounds);
/* Normally, the array bound must be an integral constant
expression. However, as an extension, we allow VLAs
- in function scopes. */
- else if (!parser->in_function_body)
+ in function scopes as long as they aren't part of a
+ parameter declaration. */
+ else if (!parser->in_function_body
+ || current_binding_level->kind == sk_function_parms)
{
- error_at (token->location,
- "array bound is not an integer constant");
+ cp_parser_error (parser,
+ "array bound is not an integer constant");
bounds = error_mark_node;
}
else if (processing_template_decl && !error_operand_p (bounds))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a7af1c643f2..a561219e5ab 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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>
PR debug/43593
diff --git a/gcc/testsuite/g++.dg/parse/ambig5.C b/gcc/testsuite/g++.dg/parse/ambig5.C
new file mode 100644
index 00000000000..e554d961f57
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/ambig5.C
@@ -0,0 +1,7 @@
+// PR c++/41786
+
+struct A { A(int, char const*); };
+int main() {
+ int i = 0, *b = &i;
+ A a(int(b[i]), "hello");
+}
diff --git a/gcc/testsuite/g++.dg/parse/varmod1.C b/gcc/testsuite/g++.dg/parse/varmod1.C
index 8f7b4eb1419..d64f04b7885 100644
--- a/gcc/testsuite/g++.dg/parse/varmod1.C
+++ b/gcc/testsuite/g++.dg/parse/varmod1.C
@@ -2,6 +2,6 @@ int main(int argc, char** argv) {
int nx = 2;
void theerror(double a[][nx+1]); // { dg-message "" }
double** a;
- theerror(a); // { dg-error "" }
+ theerror(a);
return 0;
}