Bug 12477 - Request to add ability to disable inline/dllimport warnings
Summary: Request to add ability to disable inline/dllimport warnings
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.1
: P3 enhancement
Target Milestone: ---
Assignee: Danny Smith
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-01 12:38 UTC by Johnny Willemsen
Modified: 2006-11-26 05:58 UTC (History)
2 users (show)

See Also:
Host: x86-cygwin
Target: x66-cygwin
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-06-30 02:42:42


Attachments
header file (95 bytes, text/plain)
2003-10-01 13:52 UTC, Johnny Willemsen
Details
inline file (55 bytes, text/plain)
2003-10-01 13:53 UTC, Johnny Willemsen
Details
main (62 bytes, text/plain)
2003-10-01 13:53 UTC, Johnny Willemsen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johnny Willemsen 2003-10-01 12:38:06 UTC
I am working on ACE/TAO (www.cs.wustl.edu/~schmidt). With the upgrade to 
cygwin GCC 3.3.1 we get a lot of warnings that we use inline with dllimport 
and that attribute is ignored. Can an option be added to disable just this 
warning. I know I can disable all, but I want to keep the others. We have one 
codebase in which inlining can be disable by setting inline=0 in gnu make and 
I don't think we get all warnings gone because of the large number of 
combinations.

D:/ACE/Cygwin/ACE_wrappers/ace/Bound_Ptr.i: In member function `
ACE_Bound_Ptr_Counter<ACE_LOCK>::~ACE_Bound_Ptr_Counter() [with ACE_LOCK = 
ACE_Null_Mutex]':
D:/ACE/Cygwin/ACE_wrappers/ace/Bound_Ptr.i:121: instantiated from `static void 
ACE_Bound_Ptr_Counter<ACE_LOCK>::detach_weak(ACE_Bound_Ptr_Counter<ACE_LOCK>*) 
[with ACE_LOCK = ACE_Null_Mutex]'
D:/ACE/Cygwin/ACE_wrappers/ace/Bound_Ptr.i:337: instantiated from 
`ACE_Weak_Bound_Ptr<X, ACE_LOCK>::~ACE_Weak_Bound_Ptr() [with X = Parent, 
ACE_LOCK = ACE_Null_Mutex]'
Bound_Ptr_Test.cpp:86: instantiated from here
D:/ACE/Cygwin/ACE_wrappers/ace/Null_Mutex.h:41: warning: inline function '
ACE_Null_Mutex::~ACE_Null_Mutex()' is declared as dllimport: attribute 
ignored.
Comment 1 Wolfgang Bangerth 2003-10-01 13:02:02 UTC
Would you mind posting a small piece of code that shows this, and
which flags are needed to trigger the problem?

Thanks
  Wolfgang
Comment 2 Johnny Willemsen 2003-10-01 13:18:18 UTC
I will have a try. Things are reproducable with ACE/TAO but I can imagine that 
this is large. Can be obtained for free from www.cs.wustl.edu/~schmidt. The 
Cygwin GCC 3.3.1 build results with GCC 3.3.1 cygwin can be found at 
http://www.cs.wustl.edu/~bugzilla/auto_compile_logs/remedy.nl_WinNT4_CygwinGCC3
2/
Comment 3 Johnny Willemsen 2003-10-01 13:19:22 UTC
Sorry, link is 
http://www.cs.wustl.edu/~bugzilla/auto_compile_logs/remedy.nl_Win2K_Cygwin/
Comment 4 Johnny Willemsen 2003-10-01 13:52:28 UTC
Created attachment 4871 [details]
header file
Comment 5 Johnny Willemsen 2003-10-01 13:53:03 UTC
Created attachment 4872 [details]
inline file
Comment 6 Johnny Willemsen 2003-10-01 13:53:21 UTC
Created attachment 4873 [details]
main
Comment 7 Johnny Willemsen 2003-10-01 13:53:42 UTC
The warnings

C:\ACElatest\ACE_wrappers>g++ -Wall -W test.cpp
In file included from T.h:10,
                 from test.cpp:1:
T.i: In member function `void T::b()':
T.i:2: warning: inline function 'void T::a()' is declared as dllimport:
   attribute ignored.
test.cpp: In function `int main()':
T.i:6: warning: inline function 'void T::b()' is declared as dllimport:
   attribute ignored.
Comment 8 Johnny Willemsen 2003-10-01 13:56:20 UTC
In ACE it is then possible to just set inline=0 to include the inline file in 
the cpp file and then the macro ACE_INLINE is used instead of inline and this 
expands then to nothing. I can imagine that more people use these kinds of 
tricks to disable inlining by hand or to handle different compilers and one of 
them has problems with inlining code.
Comment 9 Johnny Willemsen 2003-10-02 08:10:48 UTC
with the attachments it can be reproduced
Comment 10 Johnny Willemsen 2003-10-07 10:22:00 UTC
set to new because I delivered the example code.
Comment 11 Danny Smith 2006-06-30 02:42:41 UTC
On today's trunk, your example no longer gives warnings. Instead it compiles, then fails with:
C:\tmp>G++ -Wall -W test.cpp 
c:\tmp/ccOGb2M9.o:test.cpp:(.text+0x1e): undefined reference to _imp___ZN1TC1Ev'
c:\tmp/ccOGb2M9.o:test.cpp:(.text+0x3b): undefined reference to `_imp___ZN1TD1Ev'
collect2: ld returned 1 exit status

OK to close?
Is that what you want
Comment 12 paragw 2006-08-14 02:38:29 UTC
This happens with Qt4 Win32 as well - lot of warnings - "warning: inline function... attribute ignored". All that's needed is a -Wno-inline-dllimport type of flag to mingw to suppress these warnings. 

Specifying dllimport to inline functions seems reasonable though - If the compiler won't inline the function (that's just a hint) people will want to specify dllimport to avoid linker errors, or no?
Comment 13 Serhiy Kachanuk 2006-08-27 16:20:26 UTC
Confirmed with qt4 on win32
Comment 14 Danny Smith 2006-08-27 21:14:55 UTC
(In reply to comment #12)
> This happens with Qt4 Win32 as well - lot of warnings - "warning: inline
> function... attribute ignored". All that's needed is a -Wno-inline-dllimport
> type of flag to mingw to suppress these warnings. 

This is current (gcc-4.2) behaviour.
What exactly is wrong with using -Wno-attributes to suppress the warnings.

Danny

========================================================================
// warn-inline-dllimport.c
__declspec (dllimport) void f1();

// inline definition (silently) overides earlier dllimport declaration
inline	void f1() {}

// inline && dllimport in definition emits warning
//  both can't be true.  
inline	__declspec (dllimport) void f2 () {}

void b()
{
  f1(); 
  f2();
}
========================================================================

compiling as:
gcc -Wall -c warn-inline-dllimport.c
produces:

warn-inline-dllimport.c:8: warning: inline function 'f2' declared as dllimport: attribute ignored


compiling as:
gcc -Wall -Wno-attributes -c warn-inline-dllimport.c
gets rid of the attribute warning
Comment 15 Andrew Pinski 2006-11-26 05:58:19 UTC
No feedback in 3 months about the -Wno-attributes option and the current behavior of GCC so closing.