public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34749]  New: Incorrect warning when applying dllimport to friend function
@ 2008-01-12 15:14 sldev327 at softmagi dot com
  2008-01-13  2:24 ` [Bug c++/34749] " bangerth at dealii dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: sldev327 at softmagi dot com @ 2008-01-12 15:14 UTC (permalink / raw)
  To: gcc-bugs

I was playing with some code and got a warning about dllimport in some
headers.  I looked around a bit and came up with this test case.

The warning seems to imply that dllimport is ignored on bar(), but looking at
the output the call to bar() is indeed mangled with __imp prefix.

I'm using MinGW g++ 4.2.1-dw2.

## begin df.cpp
__attribute__((dllimport)) int bar();

class Foo
{
private:
    int foo();
    friend __attribute__((dllimport)) int bar();
};

int Foo::foo()
{
    return bar();
}
## end df.cpp

D:> g++ -S df.cpp
df.cpp:7: warning: 'int bar()' redeclared without dllimport attribute:
previous dllimport ignored

D:> g++ -v
Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.2.1-2-src/configure --with-gcc
--enable-libgomp --host =mingw32 --build=mingw32 --target=mingw32
--program-suffix=-dw2 --with-arch=i486 --with-tune=generic
--disable-werror --prefix=/mingw --with-local-prefix=/mingw
--enable-threads --disable-nls --enable-languages=c,c+
+,fortran,objc,obj-c++,ad a --disable-win32-registry
--disable-sjlj-exceptions --enable-libstdcxx-debug --
enable-cxx-flags=-fno-function-sections -fno-data-sections
--enable-version-spec ific-runtime-libs --disable-bootstrap Thread
model: win32 gcc version 4.2.1-dw2 (mingw32-2)


-- 
           Summary: Incorrect warning when applying dllimport to friend
                    function
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sldev327 at softmagi dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
@ 2008-01-13  2:24 ` bangerth at dealii dot org
  2008-01-13 10:23 ` sldev327 at softmagi dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2008-01-13  2:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2008-01-13 02:12 -------
One could make the argument that the dllimport specifier is
a storage-class-specifier which, per 11.4/6 is not allowed on
the friend declaration. Since a friend function declaration
needs to be preceded by a declaration of the function itself,
it will always be sufficient if the dllimport specifier is only
on the original function declaration.

I therefore think that the PR is invalid, but leave the final decision 
to someone with more knowledge.

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
  2008-01-13  2:24 ` [Bug c++/34749] " bangerth at dealii dot org
@ 2008-01-13 10:23 ` sldev327 at softmagi dot com
  2008-01-13 10:24 ` dannysmith at users dot sourceforge dot net
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: sldev327 at softmagi dot com @ 2008-01-13 10:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sldev327 at softmagi dot com  2008-01-13 05:52 -------
I as well will leave the argument about syntax to more knowledgeable people.

As to the validity of this PR, at the very least g++'s behavior is
inconsistent.    I suppose a case like df3.cpp is what the warning was intended
for.

g++ warns about __attribute__((dllimport)) not being there on line 7 of df.cpp
(when in truth it is), and then goes on to honor it anyway as you can see
comparing the output df.s and df3.s.

## begin df3.cpp
__attribute__((dllimport)) int bar();

class Foo
{
private:
    int foo();
    friend int bar();  // dllimport removed
};

int Foo::foo()
{
    return bar();
}
# end df3.cpp

D:> g++ -S df3.cpp
df3.cpp:7: warning: 'int bar()' redeclared without dllimport attribute:
previous dllimport ignored

D:> diff -u df.s df3.s
--- df.s        Sun Jan 13 14:02:58 2008
+++ df3.s       Sun Jan 13 14:04:51 2008
@@ -1,4 +1,4 @@
-       .file   "df.cpp"
+       .file   "df3.cpp"
        .text
        .align 2
 .globl __ZN3Foo3fooEv
@@ -11,8 +11,7 @@
 LCFI1:
        subl    $8, %esp
 LCFI2:
-       movl    __imp___Z3barv, %eax
-       call    *%eax
+       call    __Z3barv
        leave
        ret
 LFE2:
@@ -55,3 +54,4 @@
        .uleb128 0x5
        .align 4
 LEFDE1:
+       .def    __Z3barv;       .scl    2;      .type   32;     .endef


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
  2008-01-13  2:24 ` [Bug c++/34749] " bangerth at dealii dot org
  2008-01-13 10:23 ` sldev327 at softmagi dot com
@ 2008-01-13 10:24 ` dannysmith at users dot sourceforge dot net
  2008-01-13 10:27 ` dannysmith at users dot sourceforge dot net
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2008-01-13 10:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dannysmith at users dot sourceforge dot net  2008-01-13 06:50 -------
(In reply to comment #1)
> One could make the argument that the dllimport specifier is
> a storage-class-specifier which, per 11.4/6 is not allowed on
> the friend declaration. Since a friend function declaration
> needs to be preceded by a declaration of the function itself,
> it will always be sufficient if the dllimport specifier is only
> on the original function declaration.
> 

MS semantics for dllimport for ordinary file scope functions, is that if a
declaration with dllimport attribute is followed by a decl without, the prior
dllimport is overriden.  Hence, the warning that Stephen shows for df3.cc  in
comment #3 may make some sense, but I do not have a MS compiler handy to see
what MS says for the friend case.  The warning does not make sense, if the 
dllimport attribute is actually honoured (as it should be) in original
testcase.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
                   ` (2 preceding siblings ...)
  2008-01-13 10:24 ` dannysmith at users dot sourceforge dot net
@ 2008-01-13 10:27 ` dannysmith at users dot sourceforge dot net
  2008-01-19 10:44 ` dannysmith at users dot sourceforge dot net
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2008-01-13 10:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from dannysmith at users dot sourceforge dot net  2008-01-13 08:32 -------
Testing a patch.


-- 

dannysmith at users dot sourceforge dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |dannysmith at users dot
                   |dot org                     |sourceforge dot net
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-01-13 08:32:51
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
                   ` (3 preceding siblings ...)
  2008-01-13 10:27 ` dannysmith at users dot sourceforge dot net
@ 2008-01-19 10:44 ` dannysmith at users dot sourceforge dot net
  2008-02-24  9:21 ` dannysmith at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2008-01-19 10:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dannysmith at users dot sourceforge dot net  2008-01-19 08:33 -------
(In reply to comment #4)
> Testing a patch.
> 

Here it is:
http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00881.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
                   ` (4 preceding siblings ...)
  2008-01-19 10:44 ` dannysmith at users dot sourceforge dot net
@ 2008-02-24  9:21 ` dannysmith at gcc dot gnu dot org
  2008-09-26  3:16 ` dannysmith at users dot sourceforge dot net
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dannysmith at gcc dot gnu dot org @ 2008-02-24  9:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dannysmith at gcc dot gnu dot org  2008-02-24 09:20 -------
Subject: Bug 34749

Author: dannysmith
Date: Sun Feb 24 09:19:39 2008
New Revision: 132585

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132585
Log:
cp
        PR c++/34749
        * friend.c (do_friend): Call cplus_decl_attributes earlier.

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

Added:
    trunk/gcc/testsuite/g++.dg/ext/dllimport13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/friend.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
                   ` (5 preceding siblings ...)
  2008-02-24  9:21 ` dannysmith at gcc dot gnu dot org
@ 2008-09-26  3:16 ` dannysmith at users dot sourceforge dot net
  2009-01-11 12:08 ` angry-kasyan at narod dot ru
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2008-09-26  3:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dannysmith at users dot sourceforge dot net  2008-09-26 03:15 -------
*** Bug 37652 has been marked as a duplicate of this bug. ***


-- 

dannysmith at users dot sourceforge dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |v dot haisman at sh dot cvut
                   |                            |dot cz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
                   ` (6 preceding siblings ...)
  2008-09-26  3:16 ` dannysmith at users dot sourceforge dot net
@ 2009-01-11 12:08 ` angry-kasyan at narod dot ru
  2009-01-12  2:07 ` dannysmith at users dot sourceforge dot net
  2009-01-13  8:12 ` angry-kasyan at narod dot ru
  9 siblings, 0 replies; 12+ messages in thread
From: angry-kasyan at narod dot ru @ 2009-01-11 12:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from angry-kasyan at narod dot ru  2009-01-11 12:08 -------
class __declspec(dllimport) QBitArray
{
//...
    friend __declspec(dllimport) QDataStream &operator<<(QDataStream &, const
QBitArray &);
    friend __declspec(dllimport) QDataStream &operator>>(QDataStream &,
QBitArray &);
//...
};

//...
__declspec(dllimport) QDataStream &operator<<(QDataStream &, const QBitArray
&);
__declspec(dllimport) QDataStream &operator>>(QDataStream &, QBitArray &);


got
..\..\include/QtCore/../../src/corelib/tools/qbitarray.h:55: warning:
'QDataStream &operator<<(QDataStream &, const QBitArray &)' redeclared without
dllimport attribute: previous dllimport ignored
..\..\include/QtCore/../../src/corelib/tools/qbitarray.h:56: warning:
'QDataStream &operator>>(QDataStream &, QBitArray &)' redeclared without
dllimport attribute: previous dllimport ignored


mingw, gcc 4.3.2(dw2)
still unfixed?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
                   ` (7 preceding siblings ...)
  2009-01-11 12:08 ` angry-kasyan at narod dot ru
@ 2009-01-12  2:07 ` dannysmith at users dot sourceforge dot net
  2009-01-13  8:12 ` angry-kasyan at narod dot ru
  9 siblings, 0 replies; 12+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2009-01-12  2:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from dannysmith at users dot sourceforge dot net  2009-01-12 02:07 -------
(In reply to comment #8)
> still unfixed?

Please provide a compilable self-contained testcase. 
Danny


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
  2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
                   ` (8 preceding siblings ...)
  2009-01-12  2:07 ` dannysmith at users dot sourceforge dot net
@ 2009-01-13  8:12 ` angry-kasyan at narod dot ru
  9 siblings, 0 replies; 12+ messages in thread
From: angry-kasyan at narod dot ru @ 2009-01-13  8:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from angry-kasyan at narod dot ru  2009-01-13 08:12 -------
(In reply to comment #9)
> (In reply to comment #8)
> > still unfixed?
> 
> Please provide a compilable self-contained testcase. 
> Danny
> 

Here is compilable testcase:

## begin df.cpp
__attribute__((dllimport)) int bar();

class Foo
{
private:
    int foo();
    friend __attribute__((dllimport)) int bar();
};

int Foo::foo()
{
    return bar();
}
## end df.cpp

> g++ -S df.cpp


I don't see that patch in 4.3.2 or in the 4.3 branch. This is fixed in
mainline, so it'll appear in 4.4, I guess.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/34749] Incorrect warning when applying dllimport to friend function
       [not found] <bug-34749-4@http.gcc.gnu.org/bugzilla/>
@ 2010-12-03 12:23 ` ktietz at gcc dot gnu.org
  0 siblings, 0 replies; 12+ messages in thread
From: ktietz at gcc dot gnu.org @ 2010-12-03 12:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |ktietz at gcc dot gnu.org
         Resolution|                            |FIXED
      Known to fail|                            |

--- Comment #11 from Kai Tietz <ktietz at gcc dot gnu.org> 2010-12-03 12:23:00 UTC ---
The reported issue was fixed for 4.4.x and there are no plans for backporting
this fix to 4.3.x branch. I'll close this bug.
I admit that we could think about to allow for prototypes only, that a
dllimport attribute remains for following non-dllimport marked prototypes. On
the other hand, it seems to be an extension.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-12-03 12:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-12 15:14 [Bug c++/34749] New: Incorrect warning when applying dllimport to friend function sldev327 at softmagi dot com
2008-01-13  2:24 ` [Bug c++/34749] " bangerth at dealii dot org
2008-01-13 10:23 ` sldev327 at softmagi dot com
2008-01-13 10:24 ` dannysmith at users dot sourceforge dot net
2008-01-13 10:27 ` dannysmith at users dot sourceforge dot net
2008-01-19 10:44 ` dannysmith at users dot sourceforge dot net
2008-02-24  9:21 ` dannysmith at gcc dot gnu dot org
2008-09-26  3:16 ` dannysmith at users dot sourceforge dot net
2009-01-11 12:08 ` angry-kasyan at narod dot ru
2009-01-12  2:07 ` dannysmith at users dot sourceforge dot net
2009-01-13  8:12 ` angry-kasyan at narod dot ru
     [not found] <bug-34749-4@http.gcc.gnu.org/bugzilla/>
2010-12-03 12:23 ` ktietz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).