[patch][pr22217] Use the most recent decl for mangling

Richard Smith richard at metafoo.co.uk
Wed Jan 21 13:30:03 PST 2015


On Tue, Jan 20, 2015 at 9:42 AM, David Majnemer
<david.majnemer at gmail.com> wrote:
> I don't think this approach would handle things like:
>
> int pr22217_foo;
> int *b = &pr22217_foo;
> extern int pr22217_foo __asm__("pr22217_bar");

I think we should either reject this code, or ignore the __asm__ with
a warning. __asm__ is effectively an attribute, and we don't support
adding attributes after we've seen the definition of an entity, for
exactly this reason. For instance:

<stdin>:3:39: warning: attribute declaration must precede definition
[-Wignored-attributes]
extern int pr22217_foo __attribute__((section("foobar")));
                                      ^
<stdin>:1:5: note: previous definition is here
int pr22217_foo;
    ^

> With your patch, pr22217_foo gets emitted.
> With gcc, pr22217_bar gets emitted.
>
> On Tue, Jan 20, 2015 at 7:30 AM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>>
>> Sorry, I attached an older version of the patch. This one has a
>> slightly simpler test.
>>
>> On 20 January 2015 at 10:29, Rafael EspĂ­ndola
>> <rafael.espindola at gmail.com> wrote:
>> > Currently clang will produce a @foo when given
>> >
>> > int foo;
>> > extern int foo __asm__("bar");
>> >
>> > The attached patch makes it produce a @bar, which is what gcc produces.
>> >
>> > I am confused by the output changes in the microsoft abi tests.
>> > Hopefully someone more familiar with it can comment on why using a
>> > more recent decl causes problems and has an idea of what should be
>> > changed to accommodate it.
>> >
>> > Cheers,
>> > Rafael
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list