Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Multiple Issues with Attribute Alias #12615

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR13162
Status NEW
Importance P enhancement
Reported by Reid Watson (reidw@google.com)
Reported on 2012-06-20 20:33:07 -0700
Last modified on 2018-10-25 20:11:52 -0700
Version trunk
Hardware PC Linux
CC baldrick@free.fr, llvm-bugs@lists.llvm.org, rafael@espindo.la, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments target.tar.gz (910 bytes, application/x-gzip)
Blocks
Blocked by
See also
Created attachment 8736
.tar.gz with five test cases and a perl script to compare output

As it stands, clang will accept a number of peculiar constructs related to
attribute alias on functions.
The idea that attribute alias is equivalent to a definition is not reflected in
the code base, so a number of obvious errors are not detected.

This includes cases such as
void foo() __attribute__((alias("bar"),alias("baz")))

I've attached a number of failing cases, along with an example of how defining
a method like

void foo() __attribute__((alias("bar"))){}

isn't detected and produces unpredictable results.

I've attached five such test cases, along with a perl script to compare the
diagnostics of clang and gcc.
Quuxplusone commented 12 years ago

Attached target.tar.gz (910 bytes, application/x-gzip): .tar.gz with five test cases and a perl script to compare output

Quuxplusone commented 12 years ago
Which gcc version did you test with?  While working on dragonegg I noticed that
gcc's behavior (eg what it considers an error) has been evolving.  Also, gcc
will
happily produce assembler that doesn't assemble, while LLVM rejects such
earlier.
Quuxplusone commented 12 years ago
(In reply to comment #1)
> Which gcc version did you test with?  While working on dragonegg I noticed
that
> gcc's behavior (eg what it considers an error) has been evolving.  Also, gcc
> will
> happily produce assembler that doesn't assemble, while LLVM rejects such
> earlier.

GCC 4.6.1 will reject all of the included test cases as erroneous
redefinitions, except for alias_and_body.c, which defines a function like:

void __attribute__((alias("target"))) foo() {puts("foo");}

GCC will compile this and execute the body of foo when run.