summaryrefslogtreecommitdiff
path: root/dev-scheme/c-wrapper/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2021-10-08 23:06:07 +0100
committerV3n3RiX <venerix@koprulu.sector>2021-10-08 23:06:07 +0100
commite23a08d0c97a0cc415aaa165da840b056f93c997 (patch)
tree4c5f7db60483518201fef36f8cc0712789a08db2 /dev-scheme/c-wrapper/files
parent391b5b359a346aff490103da7dddc85047f83830 (diff)
gentoo resync : 08.10.2021
Diffstat (limited to 'dev-scheme/c-wrapper/files')
-rw-r--r--dev-scheme/c-wrapper/files/c-wrapper-clang.patch71
-rw-r--r--dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch142
-rw-r--r--dev-scheme/c-wrapper/files/c-wrapper-float128.patch79
-rw-r--r--dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch42
-rw-r--r--dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch149
5 files changed, 459 insertions, 24 deletions
diff --git a/dev-scheme/c-wrapper/files/c-wrapper-clang.patch b/dev-scheme/c-wrapper/files/c-wrapper-clang.patch
new file mode 100644
index 000000000000..ba39e74df9cf
--- /dev/null
+++ b/dev-scheme/c-wrapper/files/c-wrapper-clang.patch
@@ -0,0 +1,71 @@
+--- a/src/c-parser.c
++++ b/src/c-parser.c
+@@ -1667,14 +1667,25 @@
+ ScmObj Scm_ParseMacroCode(ScmObj in, ScmObj macro_list)
+ {
+ static ScmObj trigger_line = SCM_FALSE;
++ static ScmObj is_gcc = SCM_TRUE;
+ ScmObj line_str;
+ ScmObj rx;
++ int n = 0;
++ int i;
+
+ /* skip the first line '# 1 "<stdin>"' */
+ Scm_ReadLineUnsafe(SCM_PORT(in));
+
+ if (SCM_FALSEP(trigger_line)) {
+- trigger_line = SCM_MAKE_STR_IMMUTABLE("# 1 \"<stdin>\"");
++ ScmObj gcc = Scm_GlobalVariableRef(SCM_FIND_MODULE(CPARSER_MODULE_NAME, TRUE), SCM_SYMBOL(SCM_INTERN("GCC")), 0);
++ if (SCM_INTP(Scm_StringScanRight(SCM_STRING(gcc), SCM_STRING(SCM_MAKE_STR_IMMUTABLE("gcc")), SCM_STRING_SCAN_INDEX))) {
++ trigger_line = SCM_MAKE_STR_IMMUTABLE("# 1 \"<stdin>\"");
++ } else if (SCM_INTP(Scm_StringScanRight(SCM_STRING(gcc), SCM_STRING(SCM_MAKE_STR_IMMUTABLE("clang")), SCM_STRING_SCAN_INDEX))) {
++ trigger_line = SCM_MAKE_STR_IMMUTABLE("# 1 \"<stdin>\" 2");
++ is_gcc = SCM_FALSE;
++ } else {
++ Scm_Error("unknown compiler");
++ }
+ }
+
+ while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
+@@ -1683,22 +1694,33 @@
+ }
+ }
+
+- rx = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+\\d+\\s+\"<stdin>\"")), 0);
++ rx = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+(\\d+)\\s+\"<stdin>\"")), 0);
+ line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
+- while (!SCM_EOFP(line_str)) {
+- ScmObj body_str = line_str;
++ for (i = 1; !SCM_EOFP(line_str); i++) {
++ ScmObj body_str;
++ ScmObj rm;
++ if (i < n) {
++ body_str = SCM_MAKE_STR_IMMUTABLE("");
++ goto parse;
++ }
++ body_str = line_str;
+ while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))
+ && SCM_STRING_LENGTH(line_str) >= 13
+ #ifdef SCM_REGEXP_MULTI_LINE
+- && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) {
++ && SCM_REGMATCHP(rm = Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) {
+ #else
+- && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str)))) {
++ && SCM_REGMATCHP(rm = Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str)))) {
+ #endif
+- if (SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
+- Scm_Error("[bug] unexpected EOF while parsing macro body");
++ if (SCM_TRUEP(is_gcc)) {
++ if (SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
++ Scm_Error("[bug] unexpected EOF while parsing macro body");
++ }
++ body_str = Scm_StringAppend2(SCM_STRING(body_str), SCM_STRING(line_str));
++ } else {
++ n = SCM_INT_VALUE(Scm_StringToNumber(SCM_STRING(Scm_RegMatchSubstr(SCM_REGMATCH(rm), SCM_MAKE_INT(1))), 10, 0));
+ }
+- body_str = Scm_StringAppend2(SCM_STRING(body_str), SCM_STRING(line_str));
+ }
++parse:
+ if (SCM_NULLP(macro_list)) {
+ Scm_Error("[bug] lost macro body");
+ } else {
diff --git a/dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch b/dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch
new file mode 100644
index 000000000000..998938a2c428
--- /dev/null
+++ b/dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch
@@ -0,0 +1,142 @@
+https://aur.archlinux.org/cgit/aur.git/tree/14_extend_parser.patch?h=gauche-c-wrapper
+
+Description: Include __int128, make statements before delcarations in functions possible and add some workaround to load x86intrin.h successfully.
+Author: Fabian Brosda <fabi3141@gmx.de>
+Last-Update: 2020-07-10
+
+--- a/lib/c-wrapper/c-parser.scm
++++ b/lib/c-wrapper/c-parser.scm
+@@ -181,6 +181,26 @@
+ ,@(reverse init-list)
+ ,@statements)))
+
++(define-maybe (%COMPOUND-STATEMENT-WITH-DECLARATION-EXT statements-before declaration-list statements)
++ (let ((var-list '())
++ (init-list '()))
++ (for-each (lambda (declaration)
++ (let* ((type (type-of declaration))
++ (identifier (name-of declaration))
++ (init-val (value-of declaration)))
++ ;; TODO: typedef in compound_statement is not supported
++ (push! var-list `(,identifier (make ,type)))
++ (when init-val
++ (push! init-list
++ `(set! ((with-module c-wrapper.c-ffi ref) ,identifier)
++ ,init-val)))))
++ declaration-list)
++ `(begin
++ ,@statements-before
++ (let* ,(reverse var-list)
++ ,@(reverse init-list)
++ ,@statements))))
++
+ (define-maybe (%REF-ARRAY v index)
+ `((with-module c-wrapper.c-ffi ref) ,v ,(%INT index)))
+
+--- a/src/c-grammar.scm
++++ b/src/c-grammar.scm
+@@ -122,6 +122,7 @@
+ (LPAREN expr RPAREN) : (%EXPR-IN-PARENS $2)
+ (LPAREN compound_statement RPAREN) : (%COMPOUND-STATEMENT $2)
+ (LPAREN type_name RPAREN LCBRA initializer_list RCBRA) : #f
++ (LPAREN type_name RPAREN LCBRA initializer_list COMMA RCBRA) : #f
+ (objc_message_expr) : $1
+ (objc_selector_expr) : $1
+ (objc_protocol_expr) : #f
+@@ -474,8 +475,8 @@
+ (LCBRA RCBRA) : (%COMPOUND-STATEMENT '(0))
+ (LCBRA statement_list RCBRA) : (%COMPOUND-STATEMENT $2)
+ (LCBRA declaration_list RCBRA) : (%COMPOUND-STATEMENT '(0))
+- (LCBRA declaration_list statement_list RCBRA)
+- : (%COMPOUND-STATEMENT-WITH-DECLARATION $2 $3)
++ (LCBRA declaration_list statement_list RCBRA) : (%COMPOUND-STATEMENT-WITH-DECLARATION $2 $3)
++ (LCBRA statement_list declaration_list statement_list RCBRA) : (%COMPOUND-STATEMENT-WITH-DECLARATION-EXT $2 $3 $4)
+ (error RCBRA) : #f
+ )
+
+--- a/src/c-lex.c
++++ b/src/c-lex.c
+@@ -361,6 +361,7 @@
+ "void",
+ "_Bool",
+ "_Float128",
++ "__int128",
+ NULL,
+ };
+ int i;
+--- a/src/c-parser.c
++++ b/src/c-parser.c
+@@ -104,6 +104,7 @@
+ DEFINE_SYM(void);
+ DEFINE_SYM(_Bool);
+ DEFINE_SYM(_Float128);
++DEFINE_SYM(__int128);
+ DEFINE_SYM(__builtin_va_list);
+ DEFINE_SYM(U_struct);
+ DEFINE_SYM(U_union);
+@@ -472,7 +473,9 @@
+ } else if (SCM_EQ(car, SYM(_Bool))) {
+ SCM_RETURN(SYM(c_int));
+ } else if (SCM_EQ(car, SYM(_Float128))) {
+ SCM_RETURN(SYM(c_double));
++ } else if (SCM_EQ(car, SYM(__int128))) {
++ SCM_RETURN(SYM(c_longlong));
+ } else if (SCM_EQ(car, SYM(__builtin_va_list))) {
+ SCM_RETURN(SCM_LIST2(SCM_LIST3(SYM(with_module), SYM(c_wrapper_c_ffi), SYM(ptr)), SYM(c_void)));
+ } else if (SCM_PAIRP(car) && SCM_EQ(SCM_CAR(car), SYM(U_struct))) {
+@@ -1024,7 +1027,11 @@
+ Scm_ParserAttributeClear();
+ td_list = Scm_MakeTypeDeclList(type_spec_list, declarator_list);
+ SCM_FOR_EACH(pair, td_list) {
+- Scm_ArgPoolAdd(SCM_TYPE_DECL_NAME(SCM_CAR(pair)));
++ // hack to avoid segfault when loading x86intrin.h
++ // TODO: why is this necessary?
++ if (!SCM_EQ(SCM_CAR(pair), SCM_FALSE)) {
++ Scm_ArgPoolAdd(SCM_TYPE_DECL_NAME(SCM_CAR(pair)));
++ }
+ }
+
+ SCM_RETURN(td_list);
+@@ -1865,6 +1872,7 @@
+ INIT_SYM(void, "void");
+ INIT_SYM(_Bool, "_Bool");
+ INIT_SYM(_Float128, "_Float128");
++ INIT_SYM(__int128, "__int128");
+ INIT_SYM(__builtin_va_list, "__builtin_va_list");
+ INIT_SYM(U_struct, "STRUCT");
+ INIT_SYM(U_union, "UNION");
+--- a/testsuite/Makefile.in
++++ b/testsuite/Makefile.in
+@@ -78,6 +78,7 @@
+ $(GOSH) -I../src -I../lib stdio-test.scm >> test.log
+ $(GOSH) -I../src -I../lib math-test.scm >> test.log
+ $(GOSH) -I../src -I../lib local-typedef.scm >> test.log
++ $(GOSH) -I../src -I../lib stmt-decl.scm >> test.log
+ $(GOSH) -I../src -I../lib inline-test.scm >> test.log
+ $(GOSH) -I../src -I../lib fptr_array-test.scm >> test.log
+ $(GOSH) -I../src -I../lib array_qualifier-test.scm >> test.log
+--- a/testsuite/stmt_decl.h
++++ b/testsuite/stmt_decl.h
+@@ -0,0 +1,6 @@
++void f(int arg1)
++{
++ arg1 = 3;
++ double tmp = arg1;
++ return tmp;
++}
+--- a/testsuite/stmt-decl.scm
++++ b/testsuite/stmt-decl.scm
+@@ -0,0 +1,13 @@
++;;;
++;;; Test include math.h
++;;;
++
++(use gauche.test)
++
++(test-start "test for statement before and after declaration in c function")
++(use c-wrapper)
++
++(c-include "stmt_decl.h")
++
++;; epilogue
++(test-end)
diff --git a/dev-scheme/c-wrapper/files/c-wrapper-float128.patch b/dev-scheme/c-wrapper/files/c-wrapper-float128.patch
new file mode 100644
index 000000000000..acd2f04407dd
--- /dev/null
+++ b/dev-scheme/c-wrapper/files/c-wrapper-float128.patch
@@ -0,0 +1,79 @@
+https://aur.archlinux.org/cgit/aur.git/tree/12_float128.patch?h=gauche-c-wrapper
+
+Description: Workaround for usage of math.h including type _Float128
+Author: Fabian Brosda <fabi3141@gmx.de>
+Last-Update: 2020-07-10
+
+--- a/src/c-lex.c
++++ b/src/c-lex.c
+@@ -360,6 +360,7 @@
+ "double",
+ "void",
+ "_Bool",
++ "_Float128",
+ NULL,
+ };
+ int i;
+--- a/src/c-parser.c
++++ b/src/c-parser.c
+@@ -103,6 +103,7 @@
+ DEFINE_SYM(double);
+ DEFINE_SYM(void);
+ DEFINE_SYM(_Bool);
++DEFINE_SYM(_Float128);
+ DEFINE_SYM(__builtin_va_list);
+ DEFINE_SYM(U_struct);
+ DEFINE_SYM(U_union);
+@@ -470,6 +471,8 @@
+ SCM_RETURN(SYM(c_void));
+ } else if (SCM_EQ(car, SYM(_Bool))) {
+ SCM_RETURN(SYM(c_int));
++ } else if (SCM_EQ(car, SYM(_Float128))) {
++ SCM_RETURN(SYM(c_double));
+ } else if (SCM_EQ(car, SYM(__builtin_va_list))) {
+ SCM_RETURN(SCM_LIST2(SCM_LIST3(SYM(with_module), SYM(c_wrapper_c_ffi), SYM(ptr)), SYM(c_void)));
+ } else if (SCM_PAIRP(car) && SCM_EQ(SCM_CAR(car), SYM(U_struct))) {
+@@ -1859,6 +1862,7 @@
+ INIT_SYM(double, "double");
+ INIT_SYM(void, "void");
+ INIT_SYM(_Bool, "_Bool");
++ INIT_SYM(_Float128, "_Float128");
+ INIT_SYM(__builtin_va_list, "__builtin_va_list");
+ INIT_SYM(U_struct, "STRUCT");
+ INIT_SYM(U_union, "UNION");
+--- a/testsuite/Makefile.in
++++ b/testsuite/Makefile.in
+@@ -73,6 +73,7 @@
+ $(GOSH) -I../src -I../lib cwrappertest.scm >> test.log
+ $(GOSH) -I../src -I../lib struct_in_union-test.scm >> test.log
+ $(GOSH) -I../src -I../lib stdio-test.scm >> test.log
++ $(GOSH) -I../src -I../lib math-test.scm >> test.log
+ $(GOSH) -I../src -I../lib inline-test.scm >> test.log
+ $(GOSH) -I../src -I../lib fptr_array-test.scm >> test.log
+ $(GOSH) -I../src -I../lib array_qualifier-test.scm >> test.log
+--- a/testsuite/math-test.scm
++++ b/testsuite/math-test.scm
+@@ -0,0 +1,23 @@
++;;;
++;;; Test include math.h
++;;;
++
++(use gauche.test)
++
++(test-start "c-wrapper (include math.h)")
++(use c-wrapper)
++
++(c-include "math.h")
++
++(test "trunc"
++ 1.0
++ (lambda ()
++ (trunc 1.9)))
++
++(test "pow"
++ 625.0
++ (lambda ()
++ (pow 5 4)))
++
++;; epilogue
++(test-end)
diff --git a/dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch b/dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch
index 98dfaa2f945c..46ab531b389a 100644
--- a/dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch
+++ b/dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch
@@ -4,46 +4,40 @@
{
static ScmObj trigger_line = SCM_FALSE;
ScmObj line_str;
-+ ScmObj regexp = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+\\d+\\s+\"<stdin>\"")), 0);
++ ScmObj rx;
/* skip the first line '# 1 "<stdin>"' */
Scm_ReadLineUnsafe(SCM_PORT(in));
-@@ -1682,16 +1683,30 @@
+@@ -1682,7 +1683,22 @@
}
}
- while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
-- if (SCM_NULLP(macro_list)) {
-+ line_str = SCM_NIL;
-+ while (!SCM_NULLP(macro_list)) {
++ rx = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+\\d+\\s+\"<stdin>\"")), 0);
++ line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
++ while (!SCM_EOFP(line_str)) {
+ ScmObj body_str = line_str;
-+ if (SCM_NULLP(body_str)
-+ && SCM_EOFP(body_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
- Scm_Error("[bug] lost macro body");
-- } else {
-- ScmObj pos_name_args = SCM_CDAR(macro_list);
-- macro_list = SCM_CDR(macro_list);
-- Scm_FilenameSet(SCM_CAAR(pos_name_args));
-- Scm_LineNumberSet(SCM_INT_VALUE(SCM_CDAR(pos_name_args)));
-- parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), line_str);
- }
+ while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))
++ && SCM_STRING_LENGTH(line_str) >= 13
+#ifdef SCM_REGEXP_MULTI_LINE
-+ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(regexp), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) {
++ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) {
+#else
-+ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(regexp), SCM_STRING(line_str)))) {
++ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str)))) {
+#endif
+ if (SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
+ Scm_Error("[bug] unexpected EOF while parsing macro body");
+ }
+ body_str = Scm_StringAppend2(SCM_STRING(body_str), SCM_STRING(line_str));
-+ line_str = SCM_NIL;
+ }
-+ ScmObj pos_name_args = SCM_CDAR(macro_list);
-+ macro_list = SCM_CDR(macro_list);
-+ Scm_FilenameSet(SCM_CAAR(pos_name_args));
-+ Scm_LineNumberSet(SCM_INT_VALUE(SCM_CDAR(pos_name_args)));
-+ parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), body_str);
+ if (SCM_NULLP(macro_list)) {
+ Scm_Error("[bug] lost macro body");
+ } else {
+@@ -1690,7 +1706,7 @@
+ macro_list = SCM_CDR(macro_list);
+ Scm_FilenameSet(SCM_CAAR(pos_name_args));
+ Scm_LineNumberSet(SCM_INT_VALUE(SCM_CDAR(pos_name_args)));
+- parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), line_str);
++ parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), body_str);
+ }
}
- SCM_RETURN(SCM_UNDEFINED);
diff --git a/dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch b/dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch
new file mode 100644
index 000000000000..70f4ffcf4cd4
--- /dev/null
+++ b/dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch
@@ -0,0 +1,149 @@
+https://aur.archlinux.org/cgit/aur.git/plain/13_local_typedef.patch?h=gauche-c-wrapper
+
+Description: Basic support for typedefs inside functions
+Author: Fabian Brosda <fabi3141@gmx.de>
+Last-Update: 2020-07-10
+
+--- a/src/c-parser.c
++++ b/src/c-parser.c
+@@ -594,6 +594,26 @@
+ }
+ }
+
++static void emit_typedef(ScmObj type_decl_list)
++{
++ ScmObj p;
++
++ SCM_FOR_EACH(p, type_decl_list) {
++ ScmObj v = SCM_CAR(p);
++ ScmObj ctype = SCM_TYPE_DECL_CTYPE(v);
++ ScmObj new_ctype = SCM_TYPE_DECL_NAME(v);
++ ScmObj sym = CParser_ctype2class_symbol(new_ctype);
++
++ Scm_DefChunkDictSetTypename(new_ctype,
++ Scm_MakeDefChunk(SYM(S_typedef),
++ new_ctype,
++ SCM_LIST1(sym),
++ SCM_LIST3(SYM(S_define), sym, ctype)));
++ Scm_InstallType(new_ctype);
++ }
++}
++
++
+ ScmObj Scm_MakeTypeDecl(ScmObj type_spec_list, ScmObj declarator)
+ {
+ ScmObj lst = SCM_NIL;
+@@ -612,6 +632,7 @@
+
+ SCM_FOR_EACH(pair, type_spec_list) {
+ if (SCM_EQ(SCM_CAR(pair), SYM(U_typedef))) {
++ emit_typedef(Scm_Cons(Scm_MakeTypeDecl(SCM_CDR(pair), declarator), lst));
+ continue;
+ }
+ lst = Scm_Cons(SCM_CAR(pair), lst);
+@@ -1542,25 +1563,6 @@
+ SCM_RETURN(SCM_UNDEFINED);
+ }
+
+-static void emit_typedef(ScmObj type_decl_list)
+-{
+- ScmObj p;
+-
+- SCM_FOR_EACH(p, type_decl_list) {
+- ScmObj v = SCM_CAR(p);
+- ScmObj ctype = SCM_TYPE_DECL_CTYPE(v);
+- ScmObj new_ctype = SCM_TYPE_DECL_NAME(v);
+- ScmObj sym = CParser_ctype2class_symbol(new_ctype);
+-
+- Scm_DefChunkDictSetTypename(new_ctype,
+- Scm_MakeDefChunk(SYM(S_typedef),
+- new_ctype,
+- SCM_LIST1(sym),
+- SCM_LIST3(SYM(S_define), sym, ctype)));
+- Scm_InstallType(new_ctype);
+- }
+-}
+-
+ static void emit_define_extern(ScmObj declaration)
+ {
+ ScmObj ctype = SCM_TYPE_DECL_CTYPE(declaration);
+--- a/testsuite/local_typedef.c
++++ b/testsuite/local_typedef.c
+@@ -0,0 +1,6 @@
++#include "local_typedef.h"
++
++int local_typedef(void)
++{
++ return helper();
++}
+--- a/testsuite/local_typedef.h
++++ b/testsuite/local_typedef.h
+@@ -0,0 +1,8 @@
++extern int local_typedef(void);
++
++int helper(void)
++{
++ typedef int _my_type;
++ _my_type ret = 1;
++ return ret;
++}
+--- a/testsuite/local-typedef.scm
++++ b/testsuite/local-typedef.scm
+@@ -0,0 +1,19 @@
++;;;
++;;; Test local typedefs
++;;;
++
++(use gauche.test)
++
++(test-start "c-wrapper (local typedefs)")
++(use c-wrapper)
++
++(c-load-library "./local_typedef")
++(c-include "./local_typedef.h")
++
++(test "local_typedef"
++ 1
++ (lambda ()
++ (local_typedef)))
++
++;; epilogue
++(test-end)
+--- a/testsuite/Makefile.in
++++ b/testsuite/Makefile.in
+@@ -57,6 +57,9 @@
+ fptr_array.$(DYLIBEXT): fptr_array.o
+ $(CC) $(LDFLAGS) $@ $<
+
++local_typedef.$(DYLIBEXT): local_typedef.o
++ $(CC) $(LDFLAGS) $@ $<
++
+ gcc_extension.$(DYLIBEXT): gcc_extension.o
+ $(CC) $(LDFLAGS) $@ $<
+
+@@ -65,7 +68,7 @@
+
+ check: $(CHECK_TARGET)
+
+-check-c: ffitest.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT)
++check-c: ffitest.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT) local_typedef.$(DYLIBEXT)
+ @rm -f test.log
+ $(GOSH) -I../src -I../lib attr-test.scm >> test.log
+ $(GOSH) -I../src -I../lib ffitest.scm >> test.log
+@@ -74,6 +77,7 @@
+ $(GOSH) -I../src -I../lib struct_in_union-test.scm >> test.log
+ $(GOSH) -I../src -I../lib stdio-test.scm >> test.log
+ $(GOSH) -I../src -I../lib math-test.scm >> test.log
++ $(GOSH) -I../src -I../lib local-typedef.scm >> test.log
+ $(GOSH) -I../src -I../lib inline-test.scm >> test.log
+ $(GOSH) -I../src -I../lib fptr_array-test.scm >> test.log
+ $(GOSH) -I../src -I../lib array_qualifier-test.scm >> test.log
+@@ -83,7 +87,7 @@
+ $(GOSH) -I../src -I../lib -I../objc objc-test.scm >> test.log
+
+ clean :
+- rm -rf core ffitest.$(DYLIBEXT) objc-test.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT) *.o $(GENERATED) *~ test.log so_locations
++ rm -rf core ffitest.$(DYLIBEXT) objc-test.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT) local_typedef.$(DYLIBEXT) *.o $(GENERATED) *~ test.log so_locations
+
+ distclean : clean
+ rm -rf $(CONFIG_GENERATED)