This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Unreviewed cygwin/mingw dllimport patch for PRs 5287. 7910,11021
- From: Jason Merrill <jason at redhat dot com>
- To: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Christopher Faylor <cgf at redhat dot com>
- Date: Wed, 02 Jul 2003 23:25:23 -0400
- Subject: Re: Unreviewed cygwin/mingw dllimport patch for PRs 5287. 7910,11021
- References: <20030702210224.9323.qmail@web21401.mail.yahoo.com>
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