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

Commit 029c7f81 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 9407

* changes:
  Fix parsing of function declarations that return pointers.
parents 84c7966e 96138992
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -4409,15 +4409,11 @@ class Compiler : public ErrorSink {
    Type* acceptDecl2(Type* pType, tokenid_t& declName,
                      bool nameAllowed, bool nameRequired,
                      bool& reportFailure) {
        int ptrCounter = 0;
        while (accept('*')) {
            ptrCounter++;
            pType = createType(TY_POINTER, pType, NULL);
        }
        pType = acceptDecl3(pType, declName, nameAllowed, nameRequired,
                            reportFailure);
        while (ptrCounter-- > 0) {
            pType = createType(TY_POINTER, pType, NULL);
        }
        return pType;
    }

+2 −6
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ void testAssignment() {
    printf("16|= 1  %d\n", a);
}

/* Can't use because int* f() is not parsed as a function decl.
int a;

int* f() {
@@ -43,24 +42,21 @@ int* f() {

void testEval() {
    a = 0;
    printf("*f() = *f() + 10;");
    printf("*f() = *f() + 10;\n");
    *f() = *f() + 10;
    printf("a = %d\n", a);
}

void testOpEval() {
    a = 0;
    printf("*f() += 10;");
    printf("*f() += 10;\n");
    *f() += 10;
    printf("a = %d\n", a);
}

*/
int main() {
    testAssignment();
    /*
    testEval();
    testOpEval();
    */
    return 0;
}
+7 −0
Original line number Diff line number Diff line
@@ -356,6 +356,13 @@ result: 0""", """2 *= 5 10
17&= 1  1
17^= 1  16
16|= 1  17
*f() = *f() + 10;
f()
f()
a = 10
*f() += 10;
f()
a = 10
""")

    def testcomma(self):