This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unreviewed cygwin/mingw dllimport patch for PRs 5287. 7910,11021


On Thu, 3 Jul 2003 07:02:24 +1000 (EST), Danny Smith <danny_r_smith_2001@yahoo.co.nz> wrote:

>  --- Jason Merrill <jason@...> wrote: > On Thu, 12 Jun 2003 08:20:42 +1000 (EST), Danny Smith
> <danny_r_smith_2001@...> wrote:
>> 
>> > My reason for the test for TREE_STATIC of dllimport'd variables in this:
>> >
>> > if (is_attribute_p ("dllimport", name)) 
>> >     &&TREE_CODE (node) == VAR_DECL)
>> >   {
>> >     if (!TREE_STATIC (node))
>> >      /* This is needed for declarations of variables within functions */
>> >       TREE_PUBLIC (node) = 1; 
>> >     DECL_EXTERNAL (node) = 1;
>> >   }
>> >
>> > /* This is for all dllimport/export'd symbols */
>> > if (! TREE_PUBLIC (node))
>> >    error ("external linkage required")
>> >
>> >
>> > is to allow this, by setting TREE_PUBLIC as well DECL_EXTERNAL:
>> >
>> > void foo()
>> > {
>> >   __attribute__((dllimport))
>> >   int foovar;     // OK,  implicit "extern" 
>> >   foovar++;
>> > }
>> 
>> That's horrible.  That should be an error; foovar is an automatic variable.
>> Does VC++ allow this?
>
> VC++ explicitly documents this as supported. 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/html/_pluslang_definitions_and_declarations.asp

So it does.  Evidently dllimport overrides the implicit 'auto'.  I still
think that's horrible, but I suppose we ought to support it.  I suppose
that what's going on is that in VC++ dllimport implies the keyword
'extern', so you can use it wherever 'extern' is valid.

So I guess this is OK.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]