编译器测试用例或如何测试编译器 [英] Compiler test cases or how to test a compiler

查看:348
本文介绍了编译器测试用例或如何测试编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译器与所有软件一样,也容易出现错误和逻辑错误。



如何验证编译器生成的输出。通常,我的问题是




  • 如何验证生成的机器代码是否正确?

    li>
  • 如何确保生成的机器代码符合语言规范。


  • 只是选择一个开源项目(在C中,如果还在C中编写一个编译器)只是通过编译器编译它。在这种情况下,如何判断编译器是如预期的行为。


  • 语言标准委员会提供的任何正式的测试用例(文献)是符合语言编译器必须满足的吗?


  • 有什么确定的给予由编译器编译的程序中的问题是编译器错误,而不是程序错误。



    - 主流编译器混淆并编译错误的任何示例?

  • $ b $

    解决方案

    是几个编译器测试套件在那里。我们使用 Plum Hall 测试套件为C编译器提供了一些运气。它包括一组大量的C代码,专门用于测试语言标准。它验证编译器可以处理语言语法和语义。


    Compilers like all software, would also be prone to bugs, logical errors.

    How does one validate the output generated by the compiler. Typically, my question is(are)

    • How to validate that the machine code generated is correct?

    • How to ensure that the machine code generated is according to the language specification.

    • Does it make sense to just pick an open source project (in C if one is also writing a compiler in C) to just compile it through the "compiler". In that case also, how do judge that the compiler is behaving as expected.

    • Are there any formal test cases (literature) provided by the language standards committee that a "language complying" compiler has to satisfy?

    • What are the sure "give aways" that the problem in a program compiled by a compiler is a compiler bug and not a program bug.

      - Any examples where mainstream compilers get confused and compile the code wrong?

    Links to any literature would be appreciated.

    解决方案

    There are several compiler test suites out there. We've had some luck using the Plum Hall test suite for a C compiler. It consists of a large set of C code specifically written to test against the language standard. It verifies that the compiler can handle the language syntax and semantics.

    这篇关于编译器测试用例或如何测试编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆