This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

preserve parameter attributes during C++ decl smashing


I'm sending this patch on Dave's behalf.

class Foo {
 void foo (char __attribute__((user("param"))) c);
};

void Foo::foo(char c) {
}

In above example the attribute is not preserved. Since there is no way to obtain the forward declaration signature once Foo::foo implementation is parsed, the attribute should be preserved.


Attached patch fixes that.



gcc/cp/ChangeLog:


2009-04-22  David Mandelin <dmandelin@mozilla.com>:
      * decl.c (duplicate_decls): Preserve parameter attributes

Thanks,
Taras
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1982,6 +1982,16 @@ duplicate_decls (tree newdecl, tree oldd
 	}
       if (! types_match || new_defines_function)
 	{
+          /* Make sure parameter attributes
+             are retained from the initial declaration. */
+          tree oldarg, newarg;
+          for (oldarg = DECL_ARGUMENTS(olddecl), 
+                 newarg = DECL_ARGUMENTS(newdecl);
+               oldarg && newarg;
+               oldarg = TREE_CHAIN(oldarg), newarg = TREE_CHAIN(newarg)) {
+            DECL_ATTRIBUTES (newarg)
+              = (*targetm.merge_decl_attributes) (oldarg, newarg);
+          }
 	  /* These need to be copied so that the names are available.
 	     Note that if the types do match, we'll preserve inline
 	     info and other bits, but if not, we won't.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]