Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87d8ccb0 authored by Jack Palevich's avatar Jack Palevich Committed by Android Git Automerger
Browse files

am c0f25335: Make pointer casting work.

Merge commit 'c0f25335' into eclair-plus-aosp

* commit 'c0f25335':
  Make pointer casting work.
parents 67132d9d c0f25335
Loading
Loading
Loading
Loading
+81 −91
Original line number Diff line number Diff line
@@ -1467,17 +1467,12 @@ class Compiler : public ErrorSink {
                if (pA->tag == TY_ARRAY && pB->tag == TY_POINTER) {
                    pA = pA->pTail;
                }
                if (typeEqual(pA, pB)) {
                    return; // OK
                }
                if (pB->pHead->tag == TY_VOID) {
                    return; // convert to void* is OK.
                }
                if (pA->tag == TY_POINTER && pB->tag == TY_POINTER
                        && isCast) {
                    return; // OK
                }
                if (! (typeEqual(pA, pB)
                        || pB->pHead->tag == TY_VOID
                        || (pA->tag == TY_POINTER && pB->tag == TY_POINTER && isCast)
                    )) {
                    error("Incompatible pointer or array types");
                }
            } else if (bitsSame(pType, pR0Type)) {
                // do nothing special
            } else {
@@ -2608,17 +2603,12 @@ class Compiler : public ErrorSink {
                if (pA->tag == TY_ARRAY && pB->tag == TY_POINTER) {
                    pA = pA->pTail;
                }
                if (typeEqual(pA, pB)) {
                    return; // OK
                }
                if (pB->pHead->tag == TY_VOID) {
                    return; // convert to void* is OK.
                }
                if (pA->tag == TY_POINTER && pB->tag == TY_POINTER
                        && isCast) {
                    return; // OK
                }
                if (! (typeEqual(pA, pB)
                        || pB->pHead->tag == TY_VOID
                        || (pA->tag == TY_POINTER && pB->tag == TY_POINTER && isCast)
                    )) {
                    error("Incompatible pointer or array types");
                }
            } else if (bitsSame(pType, pR0Type)) {
                // do nothing special
            } else if (isFloatType(pType) && isFloatType(pR0Type)) {
+9 −0
Original line number Diff line number Diff line
// See http://b/2071670

int main() {
    float f = 10.0f;
    float* floatPointer = &f;
    // The following line used to incorrectly error: "Incompatible pointer or array types"
    int* buffer = (int*) floatPointer;
    return *buffer;
}
+6 −0
Original line number Diff line number Diff line
@@ -458,6 +458,12 @@ result: 3
result: 4
""","""""")

    def testB2071670(self):
        self.compileCheck(["-R", "data/b2071670.c"], """Executing compiled code:
result: 1092616192
""","""""")


def main():
    checkEnvironment()
    parseArgv()