aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2011-12-05 15:46:30 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-12-05 15:46:30 +0000
commit12c574caf6f0766266813fef7be8a2367a9d0700 (patch)
tree292616bb2c39f1b2c5daf646dd779ba4a6719c13 /gcc
parent546d314cf6a6bc23a151fa63143b23907c20bc0d (diff)
downloadgcc-12c574caf6f0766266813fef7be8a2367a9d0700.zip
gcc-12c574caf6f0766266813fef7be8a2367a9d0700.tar.gz
gcc-12c574caf6f0766266813fef7be8a2367a9d0700.tar.bz2
re PR c++/51404 ([c++0x] [4.7 Regression] ICE with invalid use of auto)
/cp 2011-12-05 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51404 * typeck2.c (build_functional_cast): Early return error_mark_node for invalid uses of 'auto'. * parser.c (cp_parser_direct_declarator): When cp_parser_constant_expression returns error do not produce further diagnostic for the bound. /testsuite 2011-12-05 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51404 * g++.dg/cpp0x/auto28.C: New. From-SVN: r182011
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c12
-rw-r--r--gcc/cp/typeck2.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto28.C4
5 files changed, 26 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8f26f23..fcd44f0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2011-12-05 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/51404
+ * typeck2.c (build_functional_cast): Early return error_mark_node
+ for invalid uses of 'auto'.
+ * parser.c (cp_parser_direct_declarator): When
+ cp_parser_constant_expression returns error do not produce further
+ diagnostic for the bound.
+
2011-12-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51313
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 2fdd675..69f1eab 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16055,18 +16055,20 @@ cp_parser_direct_declarator (cp_parser* parser,
&non_constant_p);
if (!non_constant_p)
/* OK */;
- /* Normally, the array bound must be an integral constant
- expression. However, as an extension, we allow VLAs
- in function scopes as long as they aren't part of a
- parameter declaration. */
+ else if (error_operand_p (bounds))
+ /* Already gave an error. */;
else if (!parser->in_function_body
|| current_binding_level->kind == sk_function_parms)
{
+ /* Normally, the array bound must be an integral constant
+ expression. However, as an extension, we allow VLAs
+ in function scopes as long as they aren't part of a
+ parameter declaration. */
cp_parser_error (parser,
"array bound is not an integer constant");
bounds = error_mark_node;
}
- else if (processing_template_decl && !error_operand_p (bounds))
+ else if (processing_template_decl)
{
/* Remember this wasn't a constant-expression. */
bounds = build_nop (TREE_TYPE (bounds), bounds);
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 70edc2f..2db3248 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1653,7 +1653,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
{
if (complain & tf_error)
error ("invalid use of %<auto%>");
- type = error_mark_node;
+ return error_mark_node;
}
if (processing_template_decl)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2091740..31aa738 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-12-05 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/51404
+ * g++.dg/cpp0x/auto28.C: New.
+
2011-12-05 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
* gcc.dg/torture/vec-cvt-1.c (FLTTEST): Call rand instead of random.
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto28.C b/gcc/testsuite/g++.dg/cpp0x/auto28.C
new file mode 100644
index 0000000..8d25016
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto28.C
@@ -0,0 +1,4 @@
+// PR c++/51404
+// { dg-options -std=c++0x }
+
+int i = auto().x; // { dg-error "invalid use of" }