User account creation filtered due to spam.

Bug 11005 - [win32] Declaration of class as friend overrides dllimport attribute.
Summary: [win32] Declaration of class as friend overrides dllimport attribute.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.0
Assignee: Danny Smith
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2003-05-27 23:33 UTC by Danny Smith
Modified: 2004-01-14 07:35 UTC (History)
1 user (show)

See Also:
Host: i386-pc-mingw32
Target: i386-pc-mingw32
Build: i386-pc-mingw32
Known to work:
Known to fail:
Last reconfirmed: 2003-07-11 15:01:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Danny Smith 2003-05-27 23:33:53 UTC
When a dllimport'ed class is declared as friend, the attribute is lost _unless_ 
the declaration has aleady been instantiated.

The following demonstrates.  The symbol Bar::bar should be marked as dllimport 
('_imp__' prefix in assembler name).  It doesn't. If the decl is instantiated 
by moving function test1() to before the declaration of Foo, then the symbol 
_is_ marked as dllimport.

This is in both 3.4 and 3.3.1 (and all earlier 3.x I have tested)

// dllfriend.C
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
class  __attribute__((dllimport)) Bar
{
  public:
    static int bar;
};

class Foo
{
  public:
    friend class  Bar ;
    int foo();
};

int Foo::foo()
{
  return Bar::bar;
}

int test1()
{
  return Bar::bar;
}

int test2()
{
  Foo aFoo;;
  return aFoo.foo();
}

// { dg-final { scan-assembler "__imp___ZN3Bar3barE" } }
Comment 1 Dara Hazeghi 2003-05-31 00:50:40 UTC
Confirmed with gcc 3.2.3, 3.3 branch and mainline (20030530).

Dara
Comment 2 Danny Smith 2003-12-11 02:26:07 UTC
Patch submitted at:
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00965.html
Comment 3 Andrew Pinski 2003-12-21 17:24:22 UTC
Dannysmith's, as he sumbitted the patch.  New one here: <http://gcc.gnu.org/ml/gcc-
patches/2003-12/msg01173.html>.
Comment 4 Steven Bosscher 2004-01-10 11:44:24 UTC
New patch at http://gcc.gnu.org/ml/gcc-patches/2003-12/msg01565.html 
Comment 5 CVS Commits 2004-01-14 07:27:14 UTC
Subject: Bug 11005

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dannysmith@gcc.gnu.org	2004-01-14 07:27:08

Modified files:
	gcc/cp         : decl.c parser.c ChangeLog 

Log message:
	PR c++/9021
	PR c++/11005
	* parser.c (cp_parser_elaborated_type_specifier): Warn about
	attributes and discard.
	* decl.c (xref_tag): Don't overwite existing attributes with
	NULL_TREE.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1172&r2=1.1173
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.153&r2=1.154
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3878&r2=1.3879

Comment 6 Danny Smith 2004-01-14 07:35:37 UTC
Fixed