gccrs: Add const checker
authorArthur Cohen <arthur.cohen@embecosm.com>
Tue, 23 Aug 2022 15:31:55 +0000 (16:31 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 13 Dec 2022 13:00:06 +0000 (14:00 +0100)
commit5215235f01665062fbe182bb0c3c49539d882ad7
tree54c3845668c1c679b56ea69585805ef6a7d5ac3b
parentb1b35204d8a186a6fadc8534e99e9161892192ac
gccrs: Add const checker

Similarly to the unsafe checker, constant evaluation can only be performed
in a few contexts and include restrictions on the Rust language. Should
the user fail to uphold those conditions, errors will be reported and the
compilation pipeline interrupted.

These contexts are as follow:

- Array type length expressions
- Array repeat length expressions
- Constants
- Statics
- Enum discriminants
- Const generic arguments

In these contexts, the user is restricted to calling only functions marked
as `const` or perform arithmetic operations only on certain types, among
other restrictions.

gcc/rust/
* checks/errors/rust-const-checker.cc: New.
* checks/errors/rust-const-checker.h: New.
gcc/rust/checks/errors/rust-const-checker.cc [new file with mode: 0644]
gcc/rust/checks/errors/rust-const-checker.h [new file with mode: 0644]