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.
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
Keywords: patch, wrong-code
Depends on:
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


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
    static int bar;

class Foo
    friend class  Bar ;
    int foo();

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

int test1()
  return Bar::bar;

int test2()
  Foo aFoo;;

// { 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).

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

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	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


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