error

error

  1. 对数组的定义

    1
    2
    3
    4
    5
    6
    7
    8
    9
    //04_arr_defn3.sy
    int main(){
    int a[4][2] = {};
    int b[4][2] = {1, 2, 3, 4, 5, 6, 7, 8};
    int c[4][2] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
    int d[4][2] = {1, 2, {3}, {5}, 7 , 8};
    int e[4][2] = {{d[2][1], c[2][1]}, {3, 4}, {5, 6}, {7, 8}};
    return e[3][1] + e[0][0] + e[0][1] + a[2][0];
    }

    ir失败

  2. visitVarDecl: array dim is not int literal,常量作为数组维数初始化

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    //05_arr_defn4.sy
    int main(){
    const int a[4][2] = {{1, 2}, {3, 4}, {}, 7};
    const int N = 3;
    int b[4][2] = {};
    int c[4][2] = {1, 2, 3, 4, 5, 6, 7, 8};
    int d[N + 1][2] = {1, 2, {3}, {5}, a[3][0], 8};
    int e[4][2][1] = {{d[2][1], {c[2][1]}}, {3, 4}, {5, 6}, {7, 8}};
    return e[3][1][0] + e[0][0][0] + e[0][1][0] + d[3][0];
    }

    好像我们就没支持常量

    我们支持了常量,我在typer里开一下常量作为数组维数初始化

  3. if-else ir生成

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    //22_if_test3.sy,几个if-test实际上相同报错
    int ififElse()
    {
    int a;
    a = 5;
    int b;
    b = 10;
    if (a == 5)
    if (b == 10)
    a = 25;
    else
    a = a + 15;

    return (a);
    }

    int main()
    {
    return (ififElse());
    }

    报错

    1
    2
    compiler: /home/ggx/home/antlr_works/install/src/frontend/IR/irgenerator.hpp:283: void IRGenerator::visitBlock(const frontend::ast::Block&, std::shared_ptr<ir::BasicBlock>&): Assertion `then' failed.
    Aborted

    好事儿啊,如果我们多多写一堆assert,debug的时候该有多么快乐

  4. 外部库putchputint调用

    目前是typer的锅,我现在开始修这个

    1
    2
    Info: visiCalltExprCall @putint(Call @ifElseIf())
    Error: SemanticError: use of undeclared function putint



本文总阅读量