| author | |
| committer | |
| log | 5d8e56c2ebf22cc1320aa26d8ed6877bd03036cb |
| tree | 04d85873cf6a94718cdc29a97d7bb0ab1d598335 |
| parent | d7b9bbecaf6ba3ee924d7744ea720c67bc8f0a1b |
| signature |
This does not completely ignore static asserts - they are validated by aro
during parsing; any failures will render an error and non-zero exit code.
Emit a warning comment that _Static_asserts are not translated - this
matches the behavior of the existing clang-based translate-c.
Aro currently does not store source locations for _Static_assert
declarations so I've hard-coded token index 0 for now.2 files changed, 9 insertions(+), 0 deletions(-)
lib/compiler/aro_translate_c.zig+2| ... | ... | @@ -228,6 +228,7 @@ fn prepopulateGlobalNameTable(c: *Context) !void { |
| 228 | 228 | const decl_name = c.tree.tokSlice(data.decl.name); |
| 229 | 229 | try c.global_names.put(c.gpa, decl_name, {}); |
| 230 | 230 | }, |
| 231 | .static_assert => {}, | |
| 231 | 232 | else => unreachable, |
| 232 | 233 | } |
| 233 | 234 | } |
| ... | ... | @@ -305,6 +306,7 @@ fn transDecl(c: *Context, scope: *Scope, decl: NodeIndex) !void { |
| 305 | 306 | => { |
| 306 | 307 | try transVarDecl(c, decl, null); |
| 307 | 308 | }, |
| 309 | .static_assert => try warn(c, &c.global_scope.base, 0, "ignoring _Static_assert declaration", .{}), | |
| 308 | 310 | else => unreachable, |
| 309 | 311 | } |
| 310 | 312 | } |
test/cases/translate_c/_Static_assert.c created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | _Static_assert(1 == 1, ""); | |
| 2 | ||
| 3 | // translate-c | |
| 4 | // target=x86_64-linux | |
| 5 | // c_frontend=aro | |
| 6 | // | |
| 7 | // tmp.c:1:1: warning: ignoring _Static_assert declaration |