Commit 0dff37fb by Mark Mitchell Committed by Mark Mitchell

re PR c++/12218 (runtime segfault when initializing global variable with pointer-to-member)

	PR c++/12218
	* varasm.c (initializer_constant_valid_p): Allow a conversion from
	an integral constant to an OFFSET_TYPE.

	PR c++/12696
	* decl.c (reshape_init): Recover quickly from errors.

	PR c++/12218
	* g++.dg/init/pm3.C: New test.

	PR c++/12696
	* g++.dg/init/error1.C: New test.

From-SVN: r74731
parent 085bd3ff
2003-12-16 Mark Mitchell <mark@codesourcery.com>
PR c++/12218
* varasm.c (initializer_constant_valid_p): Allow a conversion from
an integral constant to an OFFSET_TYPE.
2003-12-16 Kazu Hirata <kazu@cs.umass.edu>
PR target/11012
......
2003-12-16 Mark Mitchell <mark@codesourcery.com>
PR c++/12696
* decl.c (reshape_init): Recover quickly from errors.
2003-12-16 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9043
......@@ -9,6 +14,9 @@
2003-12-16 Mark Mitchell <mark@codesourcery.com>
PR c++/12696
* decl.c (reshape_init): Recover quickly from errors.
PR c++/13275
* lex.c (reswords): Add "__offsetof" and "__offsetof__".
* parser.c (cp_parser): Add in_offsetof_p.
......
......@@ -4271,8 +4271,11 @@ reshape_init (tree type, tree *initp)
empty class shall have the form of an empty
initializer-list {}. */
if (!brace_enclosed_p)
error ("initializer for `%T' must be brace-enclosed",
type);
{
error ("initializer for `%T' must be brace-enclosed",
type);
return error_mark_node;
}
}
else
{
......@@ -4297,6 +4300,8 @@ reshape_init (tree type, tree *initp)
break;
field_init = reshape_init (TREE_TYPE (field), initp);
if (field_init == error_mark_node)
return error_mark_node;
TREE_CHAIN (field_init) = CONSTRUCTOR_ELTS (new_init);
CONSTRUCTOR_ELTS (new_init) = field_init;
/* [dcl.init.aggr]
......@@ -4327,6 +4332,8 @@ reshape_init (tree type, tree *initp)
tree element_init;
element_init = reshape_init (TREE_TYPE (type), initp);
if (element_init == error_mark_node)
return error_mark_node;
TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init);
CONSTRUCTOR_ELTS (new_init) = element_init;
if (TREE_PURPOSE (element_init))
......
2003-12-16 Mark Mitchell <mark@codesourcery.com>
PR c++/12696
* g++.dg/init/error1.C: New test.
PR c++/12218
* g++.dg/init/pm3.C: New test.
2003-12-17 Joseph S. Myers <jsm@polyomino.org.uk>
PR c/3347
......
// PR c++/12696
struct A {
static float b[10]; // { dg-error "" }
}
float A::b[] = {1,2,3}; // { dg-error "" }
// PR c++/12218
// { dg-do run }
struct C { int i, j; };
typedef int C::*mPtr;
extern const mPtr should_be_0 = &C::i;
extern const mPtr should_be_4 = &C::j;
int main () {
}
......@@ -3592,7 +3592,8 @@ initializer_constant_valid_p (tree value, tree endtype)
/* Likewise conversions from int to pointers, but also allow
conversions from 0. */
if (POINTER_TYPE_P (TREE_TYPE (value))
if ((POINTER_TYPE_P (TREE_TYPE (value))
|| TREE_CODE (TREE_TYPE (value)) == OFFSET_TYPE)
&& INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
{
if (integer_zerop (TREE_OPERAND (value, 0)))
......
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