aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-01-12 20:44:33 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-01-12 20:44:33 +0100
commit634b5df5d5c0ccfaa523ca0f9a737df3c0f28372 (patch)
tree7eb464794074dac1ac24e5ca0d2dc38255415b91 /gcc/cp
parent89b7d5e1898644c9bfd7012181f18cc4523e29cc (diff)
downloadgcc-634b5df5d5c0ccfaa523ca0f9a737df3c0f28372.zip
gcc-634b5df5d5c0ccfaa523ca0f9a737df3c0f28372.tar.gz
gcc-634b5df5d5c0ccfaa523ca0f9a737df3c0f28372.tar.bz2
re PR c/32041 (offsetof buglet)
PR c/32041 * c-parser.c (c_parser_postfix_expression): Allow `->' in offsetof member-designator, handle it as `[0].'. * parser.c (cp_parser_builtin_offsetof): Allow `->' in offsetof member-designator, handle it as `[0].'. * gcc.dg/pr32041.c: New test. * g++.dg/parse/offsetof9.C: New test. From-SVN: r143305
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/parser.c14
2 files changed, 14 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index de7d1ab..c81a1e6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2009-01-12 Jakub Jelinek <jakub@redhat.com>
+ PR c/32041
+ * parser.c (cp_parser_builtin_offsetof): Allow `->' in
+ offsetof member-designator, handle it as `[0].'.
+
PR c++/38794
* decl.c (start_function): If grokdeclarator hasn't returned
FUNCTION_DECL nor error_mark_node, issue diagnostics.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index f497d66..bf742eea 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1,6 +1,6 @@
/* C++ Parser.
Copyright (C) 2000, 2001, 2002, 2003, 2004,
- 2005, 2007, 2008 Free Software Foundation, Inc.
+ 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
This file is part of GCC.
@@ -6627,7 +6627,8 @@ cp_parser_constant_expression (cp_parser* parser,
offsetof-member-designator:
id-expression
| offsetof-member-designator "." id-expression
- | offsetof-member-designator "[" expression "]" */
+ | offsetof-member-designator "[" expression "]"
+ | offsetof-member-designator "->" id-expression */
static tree
cp_parser_builtin_offsetof (cp_parser *parser)
@@ -6670,11 +6671,16 @@ cp_parser_builtin_offsetof (cp_parser *parser)
expr = cp_parser_postfix_open_square_expression (parser, expr, true);
break;
+ case CPP_DEREF:
+ /* offsetof-member-designator "->" identifier */
+ expr = grok_array_decl (expr, integer_zero_node);
+ /* FALLTHRU */
+
case CPP_DOT:
/* offsetof-member-designator "." identifier */
cp_lexer_consume_token (parser->lexer);
- expr = cp_parser_postfix_dot_deref_expression (parser, CPP_DOT, expr,
- true, &dummy,
+ expr = cp_parser_postfix_dot_deref_expression (parser, CPP_DOT,
+ expr, true, &dummy,
token->location);
break;