[LLVMdev] Why Is This Illegal?
Chris Lattner
sabre at nondot.org
Fri Jun 9 11:04:14 PDT 2006
On Fri, 9 Jun 2006, Reid Spencer wrote:
> Can anyone tell me where my blunder is in the following program?
> llvm-as reports:
> llvm-as: testit.ll:11: Can't store 'opaque *' into space of type 'opaque
> *'!
>
> Which doesn't seem to make sense to me. What is it that is illegal about
> storing a pointer to opaque in a space that is of type pointer to
> opaque? Is it just that you can't store pointers to opaque?
The problem is that all instances of the string "opaque" are different
types in .ll files. Try using something like:
%opaque1 = type opaque
%opaque2 = type opaque
at the top, then use %opaque1/%opaque2/.. whereever you need them (or use
even better names). This way, each distinct opaque type is only
"mentioned" once and you are explicit about which opaque type you are
using.
-Chris
> %path = internal constant [11 x sbyte] c"/some/path\00"
>
> implementation ; Functions:
>
> declare opaque* %open(sbyte*)
>
> internal int %testme(int, sbyte**) {
> %stdout = alloca opaque*
> %pathp = getelementptr [11 x sbyte]* %path, uint 0, uint 0
> %handle = call opaque* %open( sbyte* %pathp )
> store opaque* %handle, opaque* %stdout ; This
> is line 11
> }
>
>
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list