cp
authordannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 24 Feb 2008 09:19:39 +0000 (09:19 +0000)
committerdannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 24 Feb 2008 09:19:39 +0000 (09:19 +0000)
PR c++/34749
* friend.c (do_friend): Call cplus_decl_attributes earlier.

testsuite
PR c++/34749
* g++.dg.ext/dllimport13.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132585 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/friend.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/dllimport13.C [new file with mode: 0644]

index 19709c1..68f9a7b 100644 (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
index ffb0baa..c4dfcc5 100644 (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;
 }
index 62ab6a8..b5f5a89 100644 (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
diff --git a/gcc/testsuite/g++.dg/ext/dllimport13.C b/gcc/testsuite/g++.dg/ext/dllimport13.C
new file mode 100644 (file)
index 0000000..a0d4ab5
--- /dev/null
@@ -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" }
+};