Commit 07166901 by Giovanni Bajo

re PR c++/14932 (cannot use offsetof to get offsets of array elements in g++ 3.4.0 prerelease)

	PR c++/14932
	* parser.c (cp_parser_postfix_expression): Allow subscript
	operator in offsetof.

	PR c++/14932
	* g++.dg/parse/offsetof4.C: New test.

From-SVN: r82538
parent 1ec4e9c3
2004-06-01 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/14932
* parser.c (cp_parser_postfix_expression): Allow subscript
operator in offsetof.
2004-05-31 Mark Mitchell <mark@codesourcery.com>
PR c++/15701
......
......@@ -3781,9 +3781,11 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
= grok_array_decl (postfix_expression, index);
idk = CP_ID_KIND_NONE;
/* Array references are not permitted in
constant-expressions. */
if (cp_parser_non_integral_constant_expression
(parser, "an array reference"))
constant-expressions (but they are allowed
in offsetof). */
if (!parser->in_offsetof_p
&& cp_parser_non_integral_constant_expression
(parser, "an array reference"))
postfix_expression = error_mark_node;
}
break;
......
2004-06-01 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/14932
* g++.dg/parse/offsetof4.C: New test.
2004-06-01 Nicola Pero <nicola@brainstorm.co.uk>
PR objc/7993
......
// { dg-do compile }
// Contributed by Bill Helfinstine <bhelf at flitterfly dot whirpon dot com>
// PR c++/14932: Allow subscript operator in offsetof
#include <cstddef>
struct A
{
int bar;
int foo[22];
};
const int off = offsetof(A, foo[12]);
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