| author | |
| committer | |
| log | d3a57b96a9bff608f9488c5d0c3c19100997373d |
| tree | 79ea9c879f80d8e3af1790c9a58d5691e8ba1ef3 |
| parent | b3c1ced2c37a8265314833fd74a105ca788db927 |
2 files changed, 11 insertions(+), 0 deletions(-)
src/translate_c.zig+4| ... | @@ -1797,6 +1797,10 @@ fn exprIsStringLiteral(expr: *const clang.Expr) bool { | ... | @@ -1797,6 +1797,10 @@ fn exprIsStringLiteral(expr: *const clang.Expr) bool { |
| 1797 | const op_expr = @ptrCast(*const clang.UnaryOperator, expr).getSubExpr(); | 1797 | const op_expr = @ptrCast(*const clang.UnaryOperator, expr).getSubExpr(); |
| 1798 | return exprIsStringLiteral(op_expr); | 1798 | return exprIsStringLiteral(op_expr); |
| 1799 | }, | 1799 | }, |
| 1800 | .ParenExprClass => { | ||
| 1801 | const op_expr = @ptrCast(*const clang.ParenExpr, expr).getSubExpr(); | ||
| 1802 | return exprIsStringLiteral(op_expr); | ||
| 1803 | }, | ||
| 1800 | else => return false, | 1804 | else => return false, |
| 1801 | } | 1805 | } |
| 1802 | } | 1806 | } |
test/run_translated_c.zig+7| ... | @@ -3,6 +3,13 @@ const tests = @import("tests.zig"); | ... | @@ -3,6 +3,13 @@ const tests = @import("tests.zig"); |
| 3 | const nl = std.cstr.line_sep; | 3 | const nl = std.cstr.line_sep; |
| 4 | 4 | ||
| 5 | pub fn addCases(cases: *tests.RunTranslatedCContext) void { | 5 | pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| 6 | cases.add("parenthesized string literal", | ||
| 7 | \\void foo(const char *s) {} | ||
| 8 | \\int main(void) { | ||
| 9 | \\	foo(("bar")); | ||
| 10 | \\} | ||
| 11 | , ""); | ||
| 12 | |||
| 6 | cases.add("variable shadowing type type", | 13 | cases.add("variable shadowing type type", |
| 7 | \\#include <stdlib.h> | 14 | \\#include <stdlib.h> |
| 8 | \\int main() { | 15 | \\int main() { |