Mercurial > hg > CbC > old > device
changeset 919:08dcc3b7c39b
fix init string in i64
author | kono |
---|---|
date | Fri, 11 Apr 2014 10:45:41 +0900 |
parents | 9b2a0f9aedf1 |
children | 485f13206916 |
files | Makefile Makefile.i64 mc-code-i64.c mc-parse.c test/macro.c |
diffstat | 5 files changed, 102 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Thu Apr 10 20:11:31 2014 +0900 +++ b/Makefile Fri Apr 11 10:45:41 2014 +0900 @@ -162,10 +162,14 @@ # -./$(MC) -Itest/ $(TARGET).c -check: mc $(MC) $(TARGET).c - -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -Wno-literal-conversion -Wno-implicit-function-declaration -Wno-implicit-int \ +ifeq ($(CC),clang) + NOWARN = -Wno-literal-conversion -Wno-implicit-function-declaration -Wno-implicit-int \ -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-return-type -Wno-bitfield-constant-conversion -Wno-tautological-compare -Wno-shift-overflow \ -Wno-unused-value +endif + +check: mc $(MC) $(TARGET).c + -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) $(NOWARN) -./b.out > $(TARGET).gcc.out -./$(MC) $(MCFLAG) $(TARGET).c -$(CC) $(TARGET).s $(MLIB) @@ -173,9 +177,7 @@ -diff $(TARGET).gcc.out $(TARGET).$(MC).out check-inline: mc $(MC) $(TARGET).c - -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -Wno-literal-conversion -Wno-implicit-function-declaration -Wno-implicit-int \ - -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-return-type -Wno-bitfield-constant-conversion -Wno-tautological-compare -Wno-shift-overflow \ - -Wno-unused-value + -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) $(NOWARN) -./b.out > $(TARGET).gcc.out -./$(MC) $(MCFLAG) -DINLINE=inline $(TARGET).c -$(CC) $(TARGET).s $(MLIB)
--- a/Makefile.i64 Thu Apr 10 20:11:31 2014 +0900 +++ b/Makefile.i64 Fri Apr 11 10:45:41 2014 +0900 @@ -1,4 +1,4 @@ -GCC = clang +GCC = gcc CC = $(GCC) -std=c99 $(CCEXT) $(M) -fgnu89-inline # -O3 # MCFLAG = -DUSE_CODE_KEYWORD @@ -162,10 +162,14 @@ # -./$(MC) -Itest/ $(TARGET).c -check: mc $(MC) $(TARGET).c - -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -Wno-literal-conversion -Wno-implicit-function-declaration -Wno-implicit-int \ +ifeq ($(CC),clang) + NOWARN = -Wno-literal-conversion -Wno-implicit-function-declaration -Wno-implicit-int \ -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-return-type -Wno-bitfield-constant-conversion -Wno-tautological-compare -Wno-shift-overflow \ -Wno-unused-value +endif + +check: mc $(MC) $(TARGET).c + -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) $(NOWARN) -./b.out > $(TARGET).gcc.out -./$(MC) $(MCFLAG) $(TARGET).c -$(CC) $(TARGET).s $(MLIB) @@ -173,9 +177,7 @@ -diff $(TARGET).gcc.out $(TARGET).$(MC).out check-inline: mc $(MC) $(TARGET).c - -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -Wno-literal-conversion -Wno-implicit-function-declaration -Wno-implicit-int \ - -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-return-type -Wno-bitfield-constant-conversion -Wno-tautological-compare -Wno-shift-overflow \ - -Wno-unused-value + -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) $(NOWARN) -./b.out > $(TARGET).gcc.out -./$(MC) $(MCFLAG) -DINLINE=inline $(TARGET).c -$(CC) $(TARGET).s $(MLIB) @@ -214,10 +216,10 @@ incpri: perl tools/incpri.pl test/*.c -tags: tags-$(ARCH) +tags: # tags-$(ARCH) tags-$(ARCH): - ctags -w mc.h mc-code.h mc-code-$(ARCH).c mc-codegen.c mc-codegen.h \ + -ctags -w mc.h mc-code.h mc-code-$(ARCH).c mc-codegen.c mc-codegen.h \ mc-parse.h mc-tree.c mc-inline.h mc-switch.h \ mc-macro.h mc-macro.c \ conv/c.c conv/c.h \
--- a/mc-code-i64.c Thu Apr 10 20:11:31 2014 +0900 +++ b/mc-code-i64.c Fri Apr 11 10:45:41 2014 +0900 @@ -41,15 +41,15 @@ static char *init_src0 = "\ -typedef struct __builtin_va_list { \\\n\ - long long_last; \\\n\ - long float_first; \\\n\ - long float_last; \\\n\ - long stack_top; \\\n\ - long arg; \\\n\ - long top; \\\n\ -} __builtin_va_list; \\\n\ - \\\n\ +typedef struct __builtin_va_list { \n\ + long long_last; \n\ + long float_first; \n\ + long float_last; \n\ + long stack_top; \n\ + long arg; \n\ + long top; \n\ +} __builtin_va_list; \n\ +\n\ #define __builtin_va_start(__ap0,v) \\\n\ { \\\n\ __builtin_va_list *__ap = &__ap0; \\\n\ @@ -62,7 +62,7 @@ if (__builtin_types_compatible_p(typeof(v),double)) \\\n\ __ap->float_first = __adr; \\\n\ __ap->arg = __adr; \\\n\ -} \\\n\ +} \n\ \n\ #define __builtin_va_arg(__ap0,type) ({ \\\n\ __builtin_va_list *__ap = &__ap0; \\\n\ @@ -80,7 +80,7 @@ __ap->arg = __ap->stack_top+16; \\\n\ } \\\n\ *((type *)(__arg)); \\\n\ -}) \\\n\ +}) \n\ \n" "\ @@ -480,8 +480,10 @@ #define __SIZEOF_LONG_LONG__ 8\n\ #define __LDBL_DIG__ 18\n\ #define __GNUC_GNU_INLINE__ 1\n\ +#define __extension__\n\ " #endif +// extension is certainly wrong #endif @@ -494,12 +496,6 @@ #endif ; -/* - - #define size_t int\n\ - -*/ - #else #include "mc-include.c"
--- a/mc-parse.c Thu Apr 10 20:11:31 2014 +0900 +++ b/mc-parse.c Fri Apr 11 10:45:41 2014 +0900 @@ -4916,10 +4916,43 @@ return hash_search(name,&scheap,i,hash0,DEF); } +// call this right after '/' +static void +skip_comment() +{ + for(;;getch()) { + if (ch=='/') { + in_comment = 1; + conv->comment_('/'); conv->comment_('/'); + while(ch!='\n') { getch(); conv->comment_(ch); } + in_comment = 0; + skipspc(); + if (ch!='/') break; + continue; + } + if(ch!='*') { + ch = *--chptr; // we already read '/', this is safe + return ; + } + in_comment = 1; + conv->comment_('/'); conv->comment_('*'); + int c; + do { + c=ch; getch(); conv->comment_(ch); + } while(!(c=='*'&&ch=='/')); + in_comment = 0; + getch(); + skipspc(); + if (ch!='/') break; + } +} + /* All strings are kept in hash table, and shared. float/long long should be shared too. + concatenate "..." comment "..." */ + static int getstring(void) { @@ -4956,6 +4989,8 @@ } possible_string_concatenate: skipspc(); + if (ch=='/') + skip_comment(); } while (ch=='"'); *cheap->ptr = 0; cheap = increment_cheap(cheap,&name); @@ -5144,6 +5179,11 @@ /* Tokenizer + output + sym + symval + nptr + gnptr */ extern int @@ -5271,23 +5311,9 @@ case ';': return sym=SM; case '/': - if(ch=='/') { - in_comment = 1; - conv->comment_('/'); conv->comment_('/'); - while(ch!='\n') { getch(); conv->comment_(ch); } - in_comment = 0; - getch(); - sc = 0; goto retry; - } - if(ch!='*') return postequ(DIV,DIV+AS); - in_comment = 1; - conv->comment_('/'); conv->comment_('*'); - do { - c=ch; getch(); conv->comment_(ch); - } while(!(c=='*'&&ch=='/')); - in_comment = 0; - getch(); - sc = 0; goto retry; + if(ch!='*'&&ch!='/') return postequ(DIV,DIV+AS); + skip_comment(); sc=0; + goto retry; case 0: case '\n': case '\f':
--- a/test/macro.c Thu Apr 10 20:11:31 2014 +0900 +++ b/test/macro.c Fri Apr 11 10:45:41 2014 +0900 @@ -68,6 +68,32 @@ */ #define stringify(x) (#x) +char *init_str = "\ +test1\n\ +test2\n\ +" +#ifdef __linux__ +// linux case +"\ +test3 linux\n\ +test4\n\ +" +#ifdef __x86_64__ +"__x86_64__\n" +#endif +#else +#ifdef __APPLE__ +"\ +test3 APPLE\n\ +test4\n\ +" +#endif +#ifdef __x86_64__ +"__x86_64__\n" +#endif +#endif +; + int main() { int a,b,e; @@ -108,7 +134,9 @@ printf("#0105:%d\n",hoge000(3)); printf("#0106:%d\n",names1(4,aho)); printf("#0107:%s\n",stringify(aho)); - f(); return 0; + printf("#0108:%s\n",init_str); + f(); + return 0; } /* For GCC 2.7 and later, we can use specific type-size attributes. */ @@ -130,7 +158,6 @@ __u_intN_t (32, __SI__); __u_intN_t (64, __DI__); - int tmp() #if 0 {