From: Danny Smith Date: Sun, 24 Feb 2008 09:19:39 +0000 (+0000) Subject: re PR c++/34749 (Incorrect warning when applying dllimport to friend function) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bdd6df52bdc1e3f280377f91f7c3a5e825a7461e;p=gcc.git re PR c++/34749 (Incorrect warning when applying dllimport to friend function) cp PR c++/34749 * friend.c (do_friend): Call cplus_decl_attributes earlier. testsuite PR c++/34749 * g++.dg.ext/dllimport13.C: New test. From-SVN: r132585 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 19709c10920..68f9a7badd1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2008-02-24 Danny Smith + + PR c++/34749 + * friend.c (do_friend): Call cplus_decl_attributes earlier. + 2008-02-22 Andrew Pinski PR C++/34715 diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index ffb0baaa600..c4dfcc58798 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -413,6 +413,13 @@ do_friend (tree ctype, tree declarator, tree decl, /* Every decl that gets here is a friend of something. */ DECL_FRIEND_P (decl) = 1; + /* Unfortunately, we have to handle attributes here. Normally we would + handle them in start_decl_1, but since this is a friend decl start_decl_1 + never gets to see it. */ + + /* Set attributes here so if duplicate decl, will have proper attributes. */ + cplus_decl_attributes (&decl, attrlist, 0); + if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR) { declarator = TREE_OPERAND (declarator, 0); @@ -582,12 +589,5 @@ do_friend (tree ctype, tree declarator, tree decl, DECL_FRIEND_P (decl) = 1; } - /* Unfortunately, we have to handle attributes here. Normally we would - handle them in start_decl_1, but since this is a friend decl start_decl_1 - never gets to see it. */ - - /* Set attributes here so if duplicate decl, will have proper attributes. */ - cplus_decl_attributes (&decl, attrlist, 0); - return decl; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 62ab6a81879..b5f5a89e975 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-02-24 Danny Smith + + PR c++/34749 + * g++.dg.ext/dllimport13.C: New test. + 2008-02-23 Francois-Xavier Coudert PR libfortran/24685 diff --git a/gcc/testsuite/g++.dg/ext/dllimport13.C b/gcc/testsuite/g++.dg/ext/dllimport13.C new file mode 100644 index 00000000000..a0d4ab555f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/dllimport13.C @@ -0,0 +1,14 @@ +// PR c++/34749 +// Ensure dllimport is handled correctly for friends + +// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} } + +int __declspec (dllimport) bar(); +int __declspec (dllimport) baz(); + +class Foo +{ +// MS requires that the dllimport attribute be specified on each declaration + friend int __declspec (dllimport) bar(); + friend int baz(); // { dg-warning "dllimport ignored" } +};