On Mon, Aug 18, 2008 at 12:31 AM, Mark Mitchell
<mark@codesourcery.com> wrote:
Bo Yang wrote:
2008-08-17 Bo Yang <techrazy.yang@gmail.com>
* decl2.c (build_memfn_type): Preserve the attributes of a
member
function by create a new type with attributes variant.
This looks much better. However, your patch does not include new
tests for
the testsuite to verify that the bug has been fixed. Please add
those and
resubmit.
Do you mean like the following?
Changelog
2008-08-17 Bo Yang <techrazy.yang@gmail.com>
* decl2.c (build_memfn_type): Preserve the attributes of a member
function by create a new type with attributes variant.
Code
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -107,7 +107,7 @@
tree
build_memfn_type (tree fntype, tree ctype, cp_cv_quals quals)
{
- tree raises;
+ tree raises, attrs;
int type_quals;
if (fntype == error_mark_node || ctype == error_mark_node)
@@ -115,10 +115,13 @@
type_quals = quals & ~TYPE_QUAL_RESTRICT;
ctype = cp_build_qualified_type (ctype, type_quals);
- fntype = build_method_type_directly (ctype, TREE_TYPE (fntype),
+ attrs = TYPE_ATTRIBUTES(fntype);
+ fntype = build_method_type_directly (ctype, TREE_TYPE(fntype),
(TREE_CODE (fntype) ==
METHOD_TYPE
? TREE_CHAIN (TYPE_ARG_TYPES
(fntype))
: TYPE_ARG_TYPES (fntype)));
+ if (attrs)
+ fntype = build_type_attribute_variant (fntype, attrs);
raises = TYPE_RAISES_EXCEPTIONS (fntype);
if (raises)
fntype = build_exception_variant (fntype, raises);
The test case:
class Base{
public:
Base(){};
~Base(){};
__attribute__((__stdcall__)) virtual void test() { };
};
typedef void (__attribute__((__stdcall__)) Base::* test)() ;
int main(int argc, char ** argv){
Base children[4];
test md = &Base::test;
for ( int i = 0; i < 4; i ++)
((children[i]).*md)();
return 0;
}