mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
translate-c: detect parenthesized string literals
This commit is contained in:
parent
b3c1ced2c3
commit
d3a57b96a9
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user