Commit 539599c1 by Mark Mitchell Committed by Mark Mitchell

re PR c++/16853 (pointer-to-member initialization from incompatible one accepted)

	PR c++/16853
	* call.c (standard_conversion): Do not accept conversions between
	pointers to members if the class types are unrelated.

	PR c++/16618
	* parser.c (cp_parser_builtin_offsetof): Cast to "const volatile
	char &" instead of just "char &".

	PR c++/16870
	* pt.c (tsubst): Just return the unknown_type_node.

	PR c++/16853
	* g++.dg/init/ptrmem1.C: New test.

	PR c++/16618
	* g++.dg/parse/offsetof5.C: New test.

	PR c++/16870
	* g++.dg/template/overload3.C: New test.

From-SVN: r85840
parent eb3643d8
2004-08-11 Mark Mitchell <mark@codesourcery.com>
PR c++/16853
* call.c (standard_conversion): Do not accept conversions between
pointers to members if the class types are unrelated.
PR c++/16618
* parser.c (cp_parser_builtin_offsetof): Cast to "const volatile
char &" instead of just "char &".
PR c++/16870
* pt.c (tsubst): Just return the unknown_type_node.
2004-08-11 Mark Mitchell <mark@codesourcery.com>
PR c++/16964
* parser.c (cp_parser_class_specifier): Robustify.
......
......@@ -716,6 +716,8 @@ standard_conversion (tree to, tree from, tree expr)
TYPE_PTRMEM_POINTED_TO_TYPE (from));
conv = build_conv (ck_pmem, from, conv);
}
else if (!same_type_p (fbase, tbase))
return NULL;
}
else if (IS_AGGR_TYPE (TREE_TYPE (from))
&& IS_AGGR_TYPE (TREE_TYPE (to))
......
......@@ -5859,7 +5859,12 @@ cp_parser_builtin_offsetof (cp_parser *parser)
we're just mirroring the traditional macro implementation. Better
would be to do the lowering of the ADDR_EXPR to flat pointer arithmetic
here rather than in build_x_unary_op. */
expr = build_reinterpret_cast (build_reference_type (char_type_node), expr);
expr = (build_reinterpret_cast
(build_reference_type (cp_build_qualified_type
(char_type_node,
TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)),
expr));
expr = build_x_unary_op (ADDR_EXPR, expr);
expr = build_reinterpret_cast (size_type_node, expr);
......
......@@ -6706,6 +6706,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
|| t == integer_type_node
|| t == void_type_node
|| t == char_type_node
|| t == unknown_type_node
|| TREE_CODE (t) == NAMESPACE_DECL)
return t;
......
2004-08-11 Mark Mitchell <mark@codesourcery.com>
PR c++/16853
* g++.dg/init/ptrmem1.C: New test.
PR c++/16618
* g++.dg/parse/offsetof5.C: New test.
PR c++/16870
* g++.dg/template/overload3.C: New test.
2004-08-11 Mark Mitchell <mark@codesourcery.com>
PR c++/16964
* g++.dg/parse/error16.C: New test.
......
// PR c++/16853
struct A {};
struct B {};
int B::* b;
int A::* a = b; // { dg-error "" }
// PR c++/16618
#include <stddef.h>
struct test
{
const char a;
};
int main()
{
offsetof(test,a);
}
// PR c++/16870
struct A
{
int operator[](int) const;
};
template<int> A foo();
A bar(A(*)());
template<int> int baz() { return (bar(&foo<0>))[0]; }
template int baz<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