aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-11-05 09:18:03 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2007-11-05 09:18:03 +0100
commitf370e66bb8c7fe4b8fe694dd79f13e834b4e7575 (patch)
tree621f3e5c2cfd28d23aa3ab9568e1678a9a43b766 /gcc
parent1b021ff438d08470cb72ee3e8e75029bda7989f1 (diff)
downloadgcc-f370e66bb8c7fe4b8fe694dd79f13e834b4e7575.zip
gcc-f370e66bb8c7fe4b8fe694dd79f13e834b4e7575.tar.gz
gcc-f370e66bb8c7fe4b8fe694dd79f13e834b4e7575.tar.bz2
re PR c++/33836 (ICE with invalid use of &&)
PR c++/33836 * parser.c (cp_parser_unary_expression): For &&label call cp_parser_non_integral_constant_expression and return error_mark_node if it returned true. * g++.dg/ext/label10.C: New test. From-SVN: r129896
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/ext/label10.C17
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5eb1dce..7869765 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2007-11-05 Jakub Jelinek <jakub@redhat.com>
+ PR c++/33836
+ * parser.c (cp_parser_unary_expression): For &&label call
+ cp_parser_non_integral_constant_expression and return error_mark_node
+ if it returned true.
+
PR c++/33969
* decl.c (grokdeclarator): Don't call build_memfn_type if type
is neither FUNCTION_TYPE nor METHOD_TYPE.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 0772c87..4729d1e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -5329,13 +5329,18 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p)
&& token->type == CPP_AND_AND)
{
tree identifier;
+ tree expression;
/* Consume the '&&' token. */
cp_lexer_consume_token (parser->lexer);
/* Look for the identifier. */
identifier = cp_parser_identifier (parser);
/* Create an expression representing the address. */
- return finish_label_address_expr (identifier);
+ expression = finish_label_address_expr (identifier);
+ if (cp_parser_non_integral_constant_expression (parser,
+ "the address of a label"))
+ expression = error_mark_node;
+ return expression;
}
}
if (unary_operator != ERROR_MARK)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3e6d744..69d30f9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2007-11-05 Jakub Jelinek <jakub@redhat.com>
+ PR c++/33836
+ * g++.dg/ext/label10.C: New test.
+
PR c++/33969
* g++.dg/other/ptrmem9.C: New test.
diff --git a/gcc/testsuite/g++.dg/ext/label10.C b/gcc/testsuite/g++.dg/ext/label10.C
new file mode 100644
index 0000000..735fe06
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/label10.C
@@ -0,0 +1,17 @@
+// PR c++/33836
+// { dg-do compile }
+// { dg-options "-std=gnu++98" }
+
+template<int N> struct A
+{
+ enum { M = && N }; // { dg-error "referenced outside|cannot appear in" }
+};
+
+A<0> a;
+
+void foo ()
+{
+ __label__ P;
+ enum { O = && P }; // { dg-error "cannot appear in" }
+ P:;
+}