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
This commit is contained in:
Danny Smith 2008-02-24 09:19:39 +00:00 committed by Danny Smith
parent 153fbec8c7
commit bdd6df52bd
4 changed files with 31 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2008-02-24 Danny Smith <dannysmith@users.sourceforge.net>
PR c++/34749
* friend.c (do_friend): Call cplus_decl_attributes earlier.
2008-02-22 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR C++/34715

View file

@ -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;
}

View file

@ -1,3 +1,8 @@
2008-02-24 Danny Smith <dannysmith@users.sourceforge.net>
PR c++/34749
* g++.dg.ext/dllimport13.C: New test.
2008-02-23 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/24685

View file

@ -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" }
};