translate-c: detect parenthesized string literals

This commit is contained in:
Veikka Tuominen 2020-12-15 22:40:04 +02:00
parent b3c1ced2c3
commit d3a57b96a9
2 changed files with 11 additions and 0 deletions

View File

@ -1797,6 +1797,10 @@ fn exprIsStringLiteral(expr: *const clang.Expr) bool {
const op_expr = @ptrCast(*const clang.UnaryOperator, expr).getSubExpr();
return exprIsStringLiteral(op_expr);
},
.ParenExprClass => {
const op_expr = @ptrCast(*const clang.ParenExpr, expr).getSubExpr();
return exprIsStringLiteral(op_expr);
},
else => return false,
}
}

View File

@ -3,6 +3,13 @@ const tests = @import("tests.zig");
const nl = std.cstr.line_sep;
pub fn addCases(cases: *tests.RunTranslatedCContext) void {
cases.add("parenthesized string literal",
\\void foo(const char *s) {}
\\int main(void) {
\\ foo(("bar"));
\\}
, "");
cases.add("variable shadowing type type",
\\#include <stdlib.h>
\\int main() {