diff options
32 files changed, 5485 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..95df35fe7c23 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,74 @@ +pkgbase = xrefactory + pkgdesc = Professional refactoring tool for C/Java and Emacs + pkgver = 1.6.10 + pkgrel = 1 + url = http://xrefactory.com + arch = x86_64 + license = custom + depends = glibc + depends = gcc + source = http://xrefactory.com/xrefactory/downloads/1.6.10/xrefactory-1.6.10-src.tgz + source = 0001-Fix-wrong-use-of-memset.patch + source = 0006-Fix-restoring-regs-after-longjmp.patch + source = 0007-Fix-mbMemory-cfMemory-tmpWorkMemory-overflowed.patch + source = 0008-The-variable-xref-set-this-frame-dispatch-data.patch + source = 0009-Parse-pragma-once-directive.patch + source = 0010-Parse-include_next-directive.patch + source = 0011-Detect-GCC-include-directories.patch + source = 0012-Detect-GCC-Predefined-Macros.patch + source = 0013-Make-exactpositionresolve-option-affecting-symbols.patch + source = 0014-Make-include-file-option-processing-file-as-input.patch + source = 0015-Parse-initializer-list-for-arrays-structs-unions.patch + source = 0016-Parse-empty-fields-in-struct-declarations.patch + source = 0017-Parse-asm-statement.patch + source = 0018-Parse-ranges-in-case-labeled-statement.patch + source = 0019-Add-missed-C-keywords.patch + source = 0020-Add-GCC-keyword-extensions.patch + source = 0021-Add-GCC-built-in-functions.patch + source = 0022-Fix-macro-expansion-for-constant-parameters.patch + source = 0023-Fix-__VA_ARGS__-expansion-in-macro-if-variable-argum.patch + source = 0024-Allow-to-process-.y-files-and-refine-C-grammar-in-ya.patch + source = 0025-Parse-typeof-keyword.patch + source = 0026-Add-showincludes-option.patch + source = 0027-Fix-if-defined-XXX-usage-references.patch + source = 0028-Check-previous-link-names-for-enums-structs-unions.patch + source = 0029-Parse-obsolete-GCC-structs-unions-initializer-list.patch + source = 0030-Fix-stdop-and-optinclude-options.patch + source = 0031-Fix-parsing-arrays-structs-unions-initializer-list.patch + source = 0033-Fix-Elisp-obsolete-functions.patch + source = 0034-Fix-Makefile.common.patch + source = 0035-Fix-clash-with-library-names.patch + md5sums = 63e10baa9a5dfce9165570e7c3897701 + md5sums = 4791f8a42e53a141ded3bd36e39b3a6d + md5sums = a00b17df920380afd6689369845acbc8 + md5sums = 12b0691bade1c2cf54f7d65be627e4ed + md5sums = d03d650d3379b9803e9c6e33d00bff01 + md5sums = 4016cb112001986916c4f8339cf15558 + md5sums = c396819441e5eefcf853c6fd95e8b235 + md5sums = d3d4a5c0b2f092a7870a3f07cf1e7ed4 + md5sums = eadbf7b35f36fbb714411852e0be7526 + md5sums = 0dbaae243f9406b086b06e74976dee56 + md5sums = 8cec60b31a4caf9a1593073d690a66bf + md5sums = 5d57e22fb4559632db54da28f98b55ff + md5sums = 727c48c11af8d7b21ce32272ab17aa39 + md5sums = 04af9e30863641db22cdc1f25ec35730 + md5sums = 2a4dd004387c50787be3adb4412f2865 + md5sums = e841cbbbafa06012db6edbe1fbc26936 + md5sums = 302bec1cc494984d108da0a392be30c8 + md5sums = 387e847d3e19d64f8883d649ba31e54b + md5sums = 081d03063e8f34223c7fa74982cc240e + md5sums = 4a1b6647233483e20fe861425e331d76 + md5sums = 4a2e62ff6a6d3c3afe4318fd90f939b5 + md5sums = 4245381509065daa86941467e5ad102c + md5sums = 2c4132f8c6f22352af7390678f4d4304 + md5sums = 1684460f5a1d16907428c868d75a27b4 + md5sums = 59cf224ed498b053ea3f84a2033d7f66 + md5sums = 5c758605b952d406b17f596afe87eeb5 + md5sums = 86c7bf7215f680e2b0d50db80ae908d6 + md5sums = 501a1993fbb4e0ac88351c10a678866d + md5sums = 8549dc467458994dda13c8fdeef7dee6 + md5sums = 633789164b37a833579fb23b1b16c5f1 + md5sums = ff4ac43651958f8e5f61f19858a87aa7 + +pkgname = xrefactory + diff --git a/0001-Fix-wrong-use-of-memset.patch b/0001-Fix-wrong-use-of-memset.patch new file mode 100644 index 000000000000..dbcde30a9e91 --- /dev/null +++ b/0001-Fix-wrong-use-of-memset.patch @@ -0,0 +1,25 @@ +From 3018e408a0255633997c800e111e70e65b11e1ee Mon Sep 17 00:00:00 2001 +From: Thomas Nilefalk <thomas@junovagen.se> +Date: Fri, 23 Dec 2016 08:04:55 +0100 +Subject: [PATCH 01/33] Fix wrong use of memset (#5) + +--- + src/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/main.c b/src/main.c +index 0c32b8b..3c53e6c 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -2489,7 +2489,7 @@ void mainTaskEntryInitialisations(int argc, char **argv) { + javaFqtTabInit( &s_javaFqtTab, FQT_CLASS_TAB_SIZE); + // initialize recursive java parsing + XX_ALLOC(s_yygstate, struct yyGlobalState); +- memset(s_yygstate, sizeof(struct yyGlobalState), 0); ++ memset(s_yygstate, 0, sizeof(struct yyGlobalState)); + s_initYygstate = s_yygstate; + + initAllInputs(); +-- +2.18.0 + diff --git a/0006-Fix-restoring-regs-after-longjmp.patch b/0006-Fix-restoring-regs-after-longjmp.patch new file mode 100644 index 000000000000..92ccdcd9d34a --- /dev/null +++ b/0006-Fix-restoring-regs-after-longjmp.patch @@ -0,0 +1,29 @@ +From 9b7ee75fa095fa0bc9408a9929a1a980fb878cae Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Fri, 23 Dec 2016 05:21:37 +0300 +Subject: [PATCH 06/33] Fix restoring regs after longjmp (causes infinite loop) + +--- + src/main.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/main.c b/src/main.c +index 3c53e6c..2c4b27b 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -3189,9 +3189,9 @@ void mainCallXref(int argc, char **argv) { + static int fc,pfc; + static int inputIn; + static int firstPassing,mess,atLeastOneProcessed; +- S_fileItem *ffc, *pffc; +- int messagePrinted = 0; +- int numberOfInputs, inputCounter, pinputCounter; ++ static S_fileItem *ffc, *pffc; ++ static int messagePrinted = 0; ++ static int numberOfInputs, inputCounter, pinputCounter; + + /* some compilers have problems with restoring regs after longjmp */ + dummy(&cxFreeBase0, &cxFreeBase, &ffc, &pffc, &inputIn, &firstPassing); +-- +2.18.0 + diff --git a/0007-Fix-mbMemory-cfMemory-tmpWorkMemory-overflowed.patch b/0007-Fix-mbMemory-cfMemory-tmpWorkMemory-overflowed.patch new file mode 100644 index 000000000000..d57062c358bd --- /dev/null +++ b/0007-Fix-mbMemory-cfMemory-tmpWorkMemory-overflowed.patch @@ -0,0 +1,44 @@ +From d7a323549e9c6626ec13a3315539a6f124e4fa44 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Mon, 16 Jan 2017 04:40:05 +0300 +Subject: [PATCH 07/33] Fix mbMemory, cfMemory, tmpWorkMemory overflowed over + borne + +--- + src/head2.h | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/head2.h b/src/head2.h +index 54f00a3..4a620a1 100644 +--- a/src/head2.h ++++ b/src/head2.h +@@ -21,11 +21,11 @@ + #define SIZE_TMP_MEM 5000 /* temporary strings, not error messages */ + + #define SIZE_ppMemory 20000 /* macro args name in define */ +-#define SIZE_mbMemory 500000 /* pending macro expansions */ ++#define SIZE_mbMemory 2000000 /* pending macro expansions */ + #define SIZE_opiMemory 150000 /* memory used to store options strings */ + #define SIZE_workMemory 10000000 /* parsing stack memory */ +-#define SIZE_tmpWorkMemory 200000 /* additional tmp parsing stack memory */ +-#define SIZE_ftMemory 4000000 /* memory for file (and class) table */ ++#define SIZE_tmpWorkMemory 400000 /* additional tmp parsing stack memory */ ++#define SIZE_ftMemory 8000000 /* memory for file (and class) table */ + + #define SIZE_ppmMemory 15000000 /* macro definitions or java class files */ + #ifdef SMALL_OLCX_MEMORY +@@ -34,9 +34,9 @@ + #define SIZE_olcxMemory 15000000 /* memory for browsing symbol stack */ + #endif + #ifdef LINEAR_ADD_REFERENCE +-#define CX_MEMORY_CHUNK_SIZE 10000000 ++#define CX_MEMORY_CHUNK_SIZE 20000000 + #else +-#define CX_MEMORY_CHUNK_SIZE 2000000 ++#define CX_MEMORY_CHUNK_SIZE 4000000 + #endif + /* memory for cross references, can be + increased also by -mf command line +-- +2.18.0 + diff --git a/0008-The-variable-xref-set-this-frame-dispatch-data.patch b/0008-The-variable-xref-set-this-frame-dispatch-data.patch new file mode 100644 index 000000000000..a0e351e85c0b --- /dev/null +++ b/0008-The-variable-xref-set-this-frame-dispatch-data.patch @@ -0,0 +1,45 @@ +From 66f90bf0038486121a3f96c56dfa27bb6247afdc Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Sun, 8 Jan 2017 03:03:18 +0300 +Subject: [PATCH 08/33] The variable xref-set-this-frame-dispatch-data stores + data to is not frame-local. + +--- + env/emacs/xref.el | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +diff --git a/env/emacs/xref.el b/env/emacs/xref.el +index 83bc4e7..1215007 100644 +--- a/env/emacs/xref.el ++++ b/env/emacs/xref.el +@@ -258,16 +258,10 @@ + ;; frame locals + ;; + +-(if (eq xref-running-under 'emacs) +- (progn +- (defvar xref-this-frame-dispatch-data nil) +- (make-variable-frame-local 'xref-this-frame-dispatch-data) +- )) +- + (defun xref-get-this-frame-dispatch-data () + (let ((res)) + (if (eq xref-running-under 'emacs) +- (setq res xref-this-frame-dispatch-data) ++ (setq res (cdr (assoc 'xref-this-frame-dispatch-data (frame-parameters (selected-frame))))) + (setq res (frame-property (selected-frame) 'xref-this-frame-dispatch-data nil)) + ) + res +@@ -275,7 +269,8 @@ + + (defun xref-set-this-frame-dispatch-data (dispatch-data) + (if (eq xref-running-under 'emacs) +- (setq xref-this-frame-dispatch-data dispatch-data) ++ (modify-frame-parameters (selected-frame) ++ (list (cons 'xref-this-frame-dispatch-data dispatch-data))) + (set-frame-property (selected-frame) + 'xref-this-frame-dispatch-data + dispatch-data) +-- +2.18.0 + diff --git a/0009-Parse-pragma-once-directive.patch b/0009-Parse-pragma-once-directive.patch new file mode 100644 index 000000000000..2745a618e43c --- /dev/null +++ b/0009-Parse-pragma-once-directive.patch @@ -0,0 +1,73 @@ +From e3c4518ee1864a38c13283e14737c4f4c23d3601 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Thu, 22 Dec 2016 04:00:34 +0300 +Subject: [PATCH 09/33] Parse "#pragma once" directive + +--- + src/yylex.c | 36 +++++++++++++++++++++++++++++++++--- + 1 file changed, 33 insertions(+), 3 deletions(-) + +diff --git a/src/yylex.c b/src/yylex.c +index b25a666..3a4c128 100644 +--- a/src/yylex.c ++++ b/src/yylex.c +@@ -524,6 +524,12 @@ static FILE *openInclude(char pchar, char *name, char **fileName) { + static void processInclude2(S_position *ipos, char pchar, char *iname) { + char *fname; + FILE *nyyin; ++ S_symbol ss,*memb; ++ int ii; ++ sprintf(tmpBuff, "PragmaOnce-%s", iname); ++ FILL_symbolBits(&ss.b,0,0,0,0,0,TypeMacro,StorageNone,0); ++ FILL_symbol(&ss,tmpBuff,tmpBuff,s_noPos,ss.b,mbody,NULL,NULL); ++ if (symTabIsMember(s_symTab, &ss, &ii, &memb)) return; + nyyin = openInclude(pchar, iname, &fname); + if (nyyin == NULL) { + assert(s_opt.taskRegime); +@@ -1047,6 +1053,32 @@ endOfMacArg: assert(0); + endOfFile:; + } + ++static void processPragma() { ++ int lex,l,v,len,ii; ++ unsigned h; ++ char *mname, *fname; ++ S_position pos; ++ S_symbol *pp; ++ ++ GetLex(lex); ++ if (lex == IDENTIFIER && !strcmp(cInput.cc, "once")) { ++ PassLex(cInput.cc,lex,l,v,h,pos, len,1); ++ fname = simpleFileName(s_fileTab.tab[pos.file]->name); ++ sprintf(tmpBuff, "PragmaOnce-%s", fname); ++ PP_ALLOCC(mname, strlen(tmpBuff)+1, char); ++ strcpy(mname, tmpBuff); ++ PP_ALLOC(pp, S_symbol); ++ FILL_symbolBits(&pp->b,0,0,0,0,0,TypeMacro,StorageNone,0); ++ FILL_symbol(pp,mname,mname,pos,pp->b,mbody,NULL,NULL); ++ symTabAdd(s_symTab,pp,&ii); ++ } ++ while (lex != '\n') {PassLex(cInput.cc,lex,l,v,h,pos, len,1); GetLex(lex);} ++ PassLex(cInput.cc,lex,l,v,h,pos, len,1); ++ return; ++endOfMacArg: assert(0); ++endOfFile:; ++} ++ + /* ***************************************************************** */ + /* CPP */ + /* ***************************************************************** */ +@@ -1124,9 +1156,7 @@ static int processCppConstruct(int lex) { + case CPP_PRAGMA: + DPRINTF1("#pragma\n"); + AddHtmlCppReference(pos); +- GetLex(lex); +- while (lex != '\n') {PassLex(cInput.cc,lex,l,v,h,pos, len,1); GetLex(lex);} +- PassLex(cInput.cc,lex,l,v,h,pos, len,1); ++ processPragma(); + break; + case CPP_LINE: + AddHtmlCppReference(pos); +-- +2.18.0 + diff --git a/0010-Parse-include_next-directive.patch b/0010-Parse-include_next-directive.patch new file mode 100644 index 000000000000..0fcb9fa14605 --- /dev/null +++ b/0010-Parse-include_next-directive.patch @@ -0,0 +1,206 @@ +From f8596af0668246ccbd26ed4289565abf9c5cd266 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Sun, 18 Jun 2017 13:17:25 +0300 +Subject: [PATCH 10/33] Parse "#include_next" directive + +--- + src/cgram.y | 2 +- + src/globals.c | 7 ++++--- + src/javagram.y | 2 +- + src/lex.c | 9 +++++---- + src/proto.h | 1 + + src/yaccgram.y | 2 +- + src/yylex.c | 27 ++++++++++++++++----------- + 7 files changed, 29 insertions(+), 21 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index af77376..e4c2474 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -162,7 +162,7 @@ + /* ************************** CPP-TOKENS ****************************** */ + /* c-only */ + %token CPP_TOKENS_START +-%token CPP_INCLUDE CPP_DEFINE CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ENDIF ++%token CPP_INCLUDE CPP_INCLUDENEXT CPP_DEFINE CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ENDIF + %token CPP_ELIF CPP_UNDEF + %token CPP_PRAGMA CPP_LINE + %token CPP_DEFINE0 /* macro with no argument */ +diff --git a/src/globals.c b/src/globals.c +index 5d331c7..777ba1e 100644 +--- a/src/globals.c ++++ b/src/globals.c +@@ -682,9 +682,10 @@ S_tokenNameIni s_tokenNameIniTab[] = { + {"'STRING_LITERAL'", STRING_LITERAL ,LAN_C}, + #ifdef DEBUG + {"'IDENTIFIER'", IDENTIFIER ,LAN_C}, +- {"'LINE_TOK'", LINE_TOK ,LAN_C}, +- {"'BLOCK_MARKER'", OL_MARKER_TOKEN ,LAN_C}, +- {"#INCLUDE", CPP_INCLUDE ,LAN_C}, ++ {"'LINE_TOK'", LINE_TOK ,LAN_C}, ++ {"'BLOCK_MARKER'", OL_MARKER_TOKEN ,LAN_C}, ++ {"#INCLUDE", CPP_INCLUDE ,LAN_C}, ++ {"#INCLUDENEXT", CPP_INCLUDENEXT ,LAN_C}, + {"#DEFINE0", CPP_DEFINE0 ,LAN_C}, + {"#DEFINE", CPP_DEFINE ,LAN_C}, + {"#IFDEF", CPP_IFDEF ,LAN_C}, +diff --git a/src/javagram.y b/src/javagram.y +index ef94800..60d79b6 100644 +--- a/src/javagram.y ++++ b/src/javagram.y +@@ -210,7 +210,7 @@ + /* ************************** CPP-TOKENS ****************************** */ + /* c-only */ + %token CPP_TOKENS_START +-%token CPP_INCLUDE CPP_DEFINE CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ENDIF ++%token CPP_INCLUDE CPP_INCLUDENEXT CPP_DEFINE CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ENDIF + %token CPP_ELIF CPP_UNDEF + %token CPP_PRAGMA CPP_LINE + %token CPP_DEFINE0 /* macro with no argument */ +diff --git a/src/lex.c b/src/lex.c +index 25bcd19..a656fc0 100644 +--- a/src/lex.c ++++ b/src/lex.c +@@ -322,12 +322,12 @@ identEnd##lab:;\ + } + + #define HandleCppToken(ch,ccc,cfin,cb,dd, cfile, cline, clb, clo) {\ +- char *ddd,tt[10];\ ++ char *ddd,tt[20];\ + int i,lcoll,scol;\ + lcoll = COLUMN_POS(ccc,clb,clo);\ + GetChar(ch,ccc,cfin,cb, clb, clo);\ + DeleteBlank(ch,ccc,cfin,cb, clb, clo);\ +- for(i=0; i<9 && (isalpha(ch) || isdigit(ch) || ch=='_') ; i++) {\ ++ for(i=0; i<19 && (isalpha(ch) || isdigit(ch) || ch=='_') ; i++) {\ + tt[i] = ch;\ + GetChar(ch,ccc,cfin,cb, clb, clo);\ + }\ +@@ -346,9 +346,10 @@ identEnd##lab:;\ + PutLexToken(CPP_ELSE,dd); PutLexPosition(cfile,cline,lcoll,dd);\ + } else if (! strcmp(tt,"endif")) {\ + PutLexToken(CPP_ENDIF,dd); PutLexPosition(cfile,cline,lcoll,dd);\ +- } else if (! strcmp(tt,"include")) { \ ++ } else if (! strcmp(tt,"include") || ! strcmp(tt,"include_next")) { \ + char endCh;\ +- PutLexToken(CPP_INCLUDE,dd); \ ++ if (! strcmp(tt,"include")) PutLexToken(CPP_INCLUDE,dd)\ ++ else PutLexToken(CPP_INCLUDENEXT,dd);\ + PutLexPosition(cfile,cline,lcoll,dd);\ + DeleteBlank(ch,ccc,cfin,cb, clb, clo);\ + if (ch == '\"' || ch == '<') {\ +diff --git a/src/proto.h b/src/proto.h +index ad93574..c050502 100644 +--- a/src/proto.h ++++ b/src/proto.h +@@ -2569,6 +2569,7 @@ void addIncludeReference C_ARG((int filenum, S_position *pos)); + void addThisFileDefineIncludeReference C_ARG((int filenum)); + void pushNewInclude C_ARG((FILE *f, S_editorBuffer *buff, char *name, char *prepend)); + void popInclude C_ARG(()); ++FILE *openInclude(char pchar, char *name, int nextFlag); + void copyDir C_ARG((char *dest, char *s, int *i)); + char *normalizeFileName C_ARG((char *name, char *relativeto)); + int addFileTabItem C_ARG((char *name, int *fileNumber)); +diff --git a/src/yaccgram.y b/src/yaccgram.y +index 4d8a34e..7e73ef2 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -172,7 +172,7 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + /* ************************** CPP-TOKENS ****************************** */ + /* c-only */ + %token CPP_TOKENS_START +-%token CPP_INCLUDE CPP_DEFINE CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ENDIF ++%token CPP_INCLUDE CPP_INCLUDENEXT CPP_DEFINE CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ENDIF + %token CPP_ELIF CPP_UNDEF + %token CPP_PRAGMA CPP_LINE + %token CPP_DEFINE0 /* macro with no argument */ +diff --git a/src/yylex.c b/src/yylex.c +index 3a4c128..2431e75 100644 +--- a/src/yylex.c ++++ b/src/yylex.c +@@ -473,7 +473,7 @@ void popInclude() { + } + } + +-static FILE *openInclude(char pchar, char *name, char **fileName) { ++FILE *openInclude(char pchar, char *name, int nextFlag) { + S_editorBuffer *er; + FILE *r; + S_stringList *ll; +@@ -505,10 +505,13 @@ static FILE *openInclude(char pchar, char *name, char **fileName) { + strcpy(nn+dlen, name); + nnlen = dlen+nmlen; + nn[nnlen]=0; ++ nnn = normalizeFileName(nn, s_cwd); ++ if (! nextFlag || strcmp(nnn, cFile.fileName) != 0) { + //&fprintf(dumpOut, "try to open <%s>\n",nn); +- er = editorFindFile(nn); +- if (er==NULL) r = fopen(nn,"r"); +- if (er!=NULL || r!=NULL) goto found; ++ er = editorFindFile(nn); ++ if (er==NULL) r = fopen(nn,"r"); ++ if (er!=NULL || r!=NULL) goto found; ++ } + }); + } + if (er==NULL && r==NULL) return(NULL); +@@ -521,8 +524,7 @@ static FILE *openInclude(char pchar, char *name, char **fileName) { + return(stdin); // NOT NULL + } + +-static void processInclude2(S_position *ipos, char pchar, char *iname) { +- char *fname; ++static void processInclude2(S_position *ipos, char pchar, char *iname, int nextFlag) { + FILE *nyyin; + S_symbol ss,*memb; + int ii; +@@ -530,7 +532,7 @@ static void processInclude2(S_position *ipos, char pchar, char *iname) { + FILL_symbolBits(&ss.b,0,0,0,0,0,TypeMacro,StorageNone,0); + FILL_symbol(&ss,tmpBuff,tmpBuff,s_noPos,ss.b,mbody,NULL,NULL); + if (symTabIsMember(s_symTab, &ss, &ii, &memb)) return; +- nyyin = openInclude(pchar, iname, &fname); ++ nyyin = openInclude(pchar, iname, nextFlag); + if (nyyin == NULL) { + assert(s_opt.taskRegime); + if (s_opt.taskRegime!=RegimeEditServer) warning(ERR_CANT_OPEN, iname); +@@ -540,7 +542,7 @@ static void processInclude2(S_position *ipos, char pchar, char *iname) { + } + + +-static void processInclude(S_position *ipos) { ++static void processInclude(S_position *ipos, int nextFlag) { + FILE *nyyin; + char *fname; + char *ccc, *cc2; +@@ -556,14 +558,14 @@ assert(0); + cInput = macStack[0]; + macStacki = 0; + } +- processInclude2(ipos, *ccc, ccc+1); ++ processInclude2(ipos, *ccc, ccc+1, nextFlag); + } else { + cInput.cc = cc2; /* unget lexem */ + lex = yylex(); + if (lex == STRING_LITERAL) { + cInput = macStack[0]; // hack, cut everything pending + macStacki = 0; +- processInclude2(ipos, '\"', yytext); ++ processInclude2(ipos, '\"', yytext, nextFlag); + } else if (lex == '<') { + // TODO!!!! + warning(ERR_ST,"Include <> after macro expansion not yet implemented, sorry\n\tuse \"\" instead"); +@@ -1098,7 +1100,10 @@ static int processCppConstruct(int lex) { + /* if (s_opt.debug) fprintf(dumpOut,"%s ",s_tokenName[lex]); */ + switch (lex) { + case CPP_INCLUDE: +- processInclude(&pos); ++ processInclude(&pos, 0); ++ break; ++ case CPP_INCLUDENEXT: ++ processInclude(&pos, 1); + break; + case CPP_DEFINE0: + AddHtmlCppReference(pos); +-- +2.18.0 + diff --git a/0011-Detect-GCC-include-directories.patch b/0011-Detect-GCC-include-directories.patch new file mode 100644 index 000000000000..195825ffd539 --- /dev/null +++ b/0011-Detect-GCC-include-directories.patch @@ -0,0 +1,104 @@ +From bb148b21408cea86a506d39bbd6bf094496f631b Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Fri, 20 Jan 2017 19:16:13 +0300 +Subject: [PATCH 11/33] Detect GCC include directories + +--- + src/main.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 66 insertions(+) + +diff --git a/src/main.c b/src/main.c +index 2c4b27b..e18721a 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -2141,6 +2141,67 @@ void mainSetLanguage(char *inFileName, int *outLanguage) { + } + } + ++ ++static int getLineFromFile(FILE *ff, char *tt, int ttsize, int *outI) { ++ int i,c,res; ++ i = 0; ++ c = getc(ff); ++ while ((c>=0 && c<=' ') || c=='\n' || c=='\t') c=getc(ff); ++ if (c==EOF) { ++ res = EOF; ++ goto fini; ++ } ++ while (c!=EOF && c!='\n') { ++ if (i < ttsize-1) tt[i++]=c; ++ c=getc(ff); ++ } ++ res = 'A'; ++ fini: ++ tt[i] = 0; ++ *outI = i; ++ return(res); ++} ++ ++static void getAndProcessGccOptions() { ++ char tt[MAX_OPTION_LEN]; ++ int len,c,isActiveSect; ++ char *ttt, *lang; ++ FILE *ff; ++ struct stat stt; ++ if (LANGUAGE(LAN_C) || LANGUAGE(LAN_YACC)) { ++ lang = "c"; ++ } ++ else if (LANGUAGE(LAN_CCC)) { ++ lang = "c++"; ++ } ++ else { ++ return; ++ } ++ isActiveSect = 0; ++ ttt = crTmpFileName_st(); ++ assert(strlen(ttt)+1 < MAX_FILE_NAME_SIZE); ++ sprintf(tmpBuff, "LANG=C cpp -v -x %s -o /dev/null /dev/null >%s 2>&1", lang, ttt); ++ system(tmpBuff); ++ ff = fopen(ttt,"r"); ++ if (ff==NULL) return; ++ while (getLineFromFile(ff,tt,MAX_OPTION_LEN,&len) != EOF) { ++ if (strncmp(tt,"#include <...> search starts here:",34)==0) { ++ isActiveSect = 1; ++ } ++ else if (strncmp(tt,"End of search list.",19)==0) { ++ isActiveSect = 0; ++ break; ++ } ++ else if ( isActiveSect ++ && statb(tt,&stt) == 0 ++ && (stt.st_mode & S_IFMT) == S_IFDIR) { ++ mainAddStringListOption(&s_opt.includeDirs, tt); ++ } ++ } ++ fclose(ff); ++ removeFile(ttt); ++} ++ + void getAndProcessXrefrcOptions(char *dffname, char *dffsect,char *project) { + int dfargc; + char **dfargv; +@@ -2232,6 +2293,7 @@ static void mainFileProcessingInitialisations( + struct stat dffstat; + char *fileName; + int lc; ++ S_stringList *tmpIncludeDirs; + + fileName = s_input_file_name; + mainSetLanguage(fileName, outLanguage); +@@ -2287,7 +2349,11 @@ static void mainFileProcessingInitialisations( + } + //& setPredefinedFileEnvVariables(fileName); + reInitCwd(dffname, dffsect); ++ tmpIncludeDirs = s_opt.includeDirs; ++ s_opt.includeDirs = NULL; + getAndProcessXrefrcOptions(dffname, dffsect, dffsect); ++ getAndProcessGccOptions(); ++ LIST_APPEND(S_stringList, s_opt.includeDirs, tmpIncludeDirs); + if (s_opt.taskRegime != RegimeEditServer && s_input_file_name == NULL) { + *outInputIn = 0; + goto fini; +-- +2.18.0 + diff --git a/0012-Detect-GCC-Predefined-Macros.patch b/0012-Detect-GCC-Predefined-Macros.patch new file mode 100644 index 000000000000..247dfdeac183 --- /dev/null +++ b/0012-Detect-GCC-Predefined-Macros.patch @@ -0,0 +1,160 @@ +From 4a56986beb1657328ba8cbe15b7ee88046dd191e Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Sat, 6 May 2017 02:53:50 +0300 +Subject: [PATCH 12/33] Detect GCC Predefined Macros + +--- + src/main.c | 33 ++++++++++++++++++++++++++++++-- + src/options.c | 52 ++++++--------------------------------------------- + 2 files changed, 37 insertions(+), 48 deletions(-) + +diff --git a/src/main.c b/src/main.c +index e18721a..46d0d29 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -2162,7 +2162,7 @@ static int getLineFromFile(FILE *ff, char *tt, int ttsize, int *outI) { + return(res); + } + +-static void getAndProcessGccOptions() { ++static void getAndProcessGccIncludeOptions() { + char tt[MAX_OPTION_LEN]; + int len,c,isActiveSect; + char *ttt, *lang; +@@ -2202,6 +2202,34 @@ static void getAndProcessGccOptions() { + removeFile(ttt); + } + ++static void getAndProcessGccDefineOptions() { ++ char tt[MAX_OPTION_LEN]; ++ int len,c; ++ char *ttt, *lang; ++ FILE *ff; ++ struct stat stt; ++ if (LANGUAGE(LAN_C) || LANGUAGE(LAN_YACC)) { ++ lang = "c"; ++ } ++ else if (LANGUAGE(LAN_CCC)) { ++ lang = "c++"; ++ } ++ else { ++ return; ++ } ++ ttt = crTmpFileName_st(); ++ assert(strlen(ttt)+1 < MAX_FILE_NAME_SIZE); ++ sprintf(tmpBuff, "LANG=C cpp -dM -x %s -o %s /dev/null 1>/dev/null 2>&1", lang, ttt); ++ system(tmpBuff); ++ ff = fopen(ttt,"r"); ++ if (ff==NULL) return; ++ while (getLineFromFile(ff,tt,MAX_OPTION_LEN,&len) != EOF) { ++ if (strncmp(tt,"#define",7)==0) addMacroDefinedByOption(tt+7); ++ } ++ fclose(ff); ++ removeFile(ttt); ++} ++ + void getAndProcessXrefrcOptions(char *dffname, char *dffsect,char *project) { + int dfargc; + char **dfargv; +@@ -2352,7 +2380,8 @@ static void mainFileProcessingInitialisations( + tmpIncludeDirs = s_opt.includeDirs; + s_opt.includeDirs = NULL; + getAndProcessXrefrcOptions(dffname, dffsect, dffsect); +- getAndProcessGccOptions(); ++ getAndProcessGccIncludeOptions(); ++ getAndProcessGccDefineOptions(); + LIST_APPEND(S_stringList, s_opt.includeDirs, tmpIncludeDirs); + if (s_opt.taskRegime != RegimeEditServer && s_input_file_name == NULL) { + *outInputIn = 0; +diff --git a/src/options.c b/src/options.c +index ba40798..555e59e 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -29,10 +29,7 @@ static char *s_standardCOptions[] = { + "-D__LINE__=0", + "-D__DATE__=\"__DATE__\"", + "-D__TIME__=\"__TIME__\"", +- "-D__STDC__=1", +- "-D__ptr_t=void*", +- "-D__wchar_t=int", +- ++ "-I", "/usr/include/", + #if defined (__WIN32__) || defined (__OS2__) /*SBD*/ + "-D_based(xxx)=", + "-D__based(xxx)=", +@@ -40,33 +37,13 @@ static char *s_standardCOptions[] = { + "-I", "\\Program Files\\DevStudio\\VC\\include\\", + "-I", "C:\\Program Files\\DevStudio\\VC\\include\\", + "-I", "D:\\Program Files\\DevStudio\\VC\\include\\", +-#else /*SBD*/ +- "-I", "/usr/include/", + #endif /*SBD*/ + #ifdef __mygnulinux__ /*SBD*/ +- "-Dlinux=1", +- "-D__linux=1", +- "-D__linux__=1", +- "-Dunix=1", +- "-D__unix=1", +- "-D__unix__=1", +-/* +- "-Di386=1", +- "-D__i386=1", +- "-D__i386__=1", +- "-D__i486__=1", +-*/ +- "-D__GNUC__=2", +- "-D__GNUC_MINOR__=7", +- "-D__ELF__=1", + "-D__attribute__(xxx) ", +- "-D__alignof__(xxx) 8", ++ "-D__alignof__(xxx) 8", ++ "-Dtypeof(xxx) int", + "-D__typeof__(xxx) int", + "-D__gnuc_va_list void", +- "-I", "/usr/lib/g++-include/", +- "-I", "/usr/lib/gcc-lib/*/*/include/", +- "-I", "/usr/include/g++/", +- "-I", "/usr/include/g++/std/", + #endif /*SBD*/ + + }; +@@ -79,33 +56,16 @@ static char *s_standardCccOptions[] = { + "-set", "dq", "\"", + "-set", "pc", "%", + "-set", "dl", "$", +- "-D__cplusplus__", +- "-D__cplusplus", + "-D__FILE__=\"__FILE__\"", + "-D__LINE__=0", + "-D__DATE__=\"__DATE__\"", + "-D__TIME__=\"__TIME__\"", +- "-D__STDC__=1", + "-I", "/usr/include/", +- + #ifdef __mygnulinux__ /*SBD*/ +- "-Dlinux=1", +- "-D__linux=1", +- "-D__linux__=1", +- "-Dunix=1", +- "-D__unix=1", +- "-D__unix__=1", +- "-D__GNUC__=2", +- "-D__GNUC_MINOR__=7", +- "-D__ELF__=1", + "-D__attribute__(xxx) ", +- "-D__alignof__(xxx) 8", +-/* "-D__typeof__(xxx) ", */ +- "-D__asm__(xxx) {}", +- "-I", "/usr/lib/g++-include/", +- "-I", "/usr/lib/gcc-lib/*/*/include/", +- "-I", "/usr/include/g++/", +- "-I", "/usr/include/g++/std", ++ "-D__alignof__(xxx) 8", ++ "-Dtypeof(xxx) int", ++ "-D__typeof__(xxx) int", + #endif /*SBD*/ + + }; +-- +2.18.0 + diff --git a/0013-Make-exactpositionresolve-option-affecting-symbols.patch b/0013-Make-exactpositionresolve-option-affecting-symbols.patch new file mode 100644 index 000000000000..fbc7af01a270 --- /dev/null +++ b/0013-Make-exactpositionresolve-option-affecting-symbols.patch @@ -0,0 +1,140 @@ +From 176accf46ad27a7f51c9f2f4a072f33d3f632d16 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Wed, 15 Mar 2017 11:51:48 +0300 +Subject: [PATCH 13/33] Make -exactpositionresolve option affecting symbols of + TypeDefault and TypeEnum symbol type + +--- + src/head.h | 2 ++ + src/semact.c | 52 +++++++++++++++++++++++++++++++++++++++------------- + 2 files changed, 41 insertions(+), 13 deletions(-) + +diff --git a/src/head.h b/src/head.h +index 1e4ab77..4b6848c 100644 +--- a/src/head.h ++++ b/src/head.h +@@ -137,6 +137,8 @@ + #define ABS(xxx) ((xxx>0)?(xxx):(-(xxx))) + #define CX_REGIME() (s_opt.taskRegime!=RegimeGenerate) + #define WORK_NEST_LEVEL0() (s_topBlock->previousTopBlock == NULL) ++#define WORK_NEST_LEVEL1() (s_topBlock->previousTopBlock != NULL && \ ++ s_topBlock->previousTopBlock->previousTopBlock == NULL) + #define CLASS_NAME_FROM_NUM(cnum) (s_fileTab.tab[cnum]->name+1) + + /* *************************************************************** */ +diff --git a/src/semact.c b/src/semact.c +index 6f1f1fe..b406879 100644 +--- a/src/semact.c ++++ b/src/semact.c +@@ -475,9 +475,7 @@ void setLocalVariableLinkName(struct symbol *p) { + sprintf(ttt+tti+len,"%c%x-%x-%x-%x", LINK_NAME_CUT_SYMBOL, + p->pos.file,p->pos.line,p->pos.coll, s_count.localVar++); + } else { +- if ( p->b.storage==StorageExtern +- || p->b.storage==StorageTypedef +- || p->b.storage==StorageConstant ) { ++ if (p->b.storage==StorageExtern && ! s_opt.exactPositionResolve) { + sprintf(ttt,"%s", p->name); + } else { + // it is now better to have name allways accessible +@@ -525,9 +523,17 @@ static void setStaticFunctionLinkName( S_symbol *p, int usage ) { + //& } + } + ++#define MEM_FROM_PREVIOUS_BLOCK(ppp) ( \ ++ s_topBlock->previousTopBlock != NULL && \ ++ ((char*)ppp) > memory && \ ++ ((char*)ppp) < memory+s_topBlock->previousTopBlock->firstFreeIndex \ ++ ) ++ + S_symbol *addNewSymbolDef(S_symbol *p, unsigned theDefaultStorage, S_symTab *tab, + int usage) { + S_typeModifiers *tt; ++ S_symbol *pp; ++ int ii; + if (p == &s_errorSymbol || p->b.symType==TypeError) return(p); + if (p->b.symType == TypeError) return(p); + assert(p && p->b.symType == TypeDefault && p->u.type); +@@ -545,16 +551,32 @@ S_symbol *addNewSymbolDef(S_symbol *p, unsigned theDefaultStorage, S_symTab *tab + tt->typedefin = p; + } + // special care is given to linkNames for local variable +- if (! WORK_NEST_LEVEL0()) { ++ if (! WORK_NEST_LEVEL0() && LANGUAGE(LAN_C) ++ || ! WORK_NEST_LEVEL1() && LANGUAGE(LAN_YACC)) { + // local scope symbol +- setLocalVariableLinkName(p); ++ if (! symTabIsMember(s_symTab,p,&ii,&pp) ++ || MEM_FROM_PREVIOUS_BLOCK(pp) && IS_DEFINITION_OR_DECL_USAGE(usage)) { ++ pp = p; ++ setLocalVariableLinkName(pp); ++ addSymbol(pp, tab); ++ } + } else if (p->b.symType==TypeDefault && p->b.storage==StorageStatic) { +- setStaticFunctionLinkName(p, usage); ++ if (! symTabIsMember(s_symTab,p,&ii,&pp)) { ++ pp = p; ++ setStaticFunctionLinkName(pp, usage); ++ addSymbol(pp, tab); ++ } ++ } else { ++ if (! symTabIsMember(s_symTab,p,&ii,&pp)) { ++ pp = p; ++ if (s_opt.exactPositionResolve) { ++ setGlobalFileDepNames(pp->name, pp, MEM_XX); ++ } ++ addSymbol(pp, tab); ++ } + } +- //& if (IS_DEFINITION_OR_DECL_USAGE(usage)) addSymbol(p, tab); // maybe this is better +- addSymbol(p, tab); +- addCxReference(p, &p->pos, usage,s_noneFileIndex, s_noneFileIndex); +- return(p); ++ addCxReference(pp, &p->pos, usage,s_noneFileIndex, s_noneFileIndex); ++ return(pp); + } + + /* this function is dead man, nowhere used */ +@@ -857,7 +879,8 @@ S_typeModifiers *simpleStrUnionSpecifier( S_idIdent *typeName, + FILL_symbolBits(&p.b,0,0, 0,0,0, type, StorageNone,0); + FILL_symbol(&p, id->name, id->name, id->p,p.b,s,NULL, NULL); + p.u.s = NULL; +- if (! symTabIsMember(s_symTab,&p,&ii,&pp)){ ++ if (! symTabIsMember(s_symTab,&p,&ii,&pp) ++ || MEM_FROM_PREVIOUS_BLOCK(pp) && IS_DEFINITION_OR_DECL_USAGE(usage)) { + //{static int c=0;fprintf(dumpOut,"str#%d\n",c++);} + XX_ALLOC(pp, S_symbol); + *pp = p; +@@ -894,7 +917,7 @@ void setGlobalFileDepNames(char *iname, S_symbol *pp, int memory) { + fname, pp->pos.line, pp->pos.coll, + LINK_NAME_CUT_SYMBOL); + } else if (iname[0]==0) { +- // anonymous structure/union ... ++ // anonymous enum/structure/union ... + filen = pp->pos.file; + pp->name=iname; pp->linkName=iname; + order = 0; +@@ -1018,9 +1041,11 @@ S_typeModifiers *simpleEnumSpecifier(S_idIdent *id, int usage) { + FILL_symbolBits(&p.b,0,0, 0,0,0, TypeEnum, StorageNone,0); + FILL_symbol(&p, id->name, id->name, id->p,p.b,enums,NULL, NULL); + p.u.enums = NULL; +- if (! symTabIsMember(s_symTab,&p,&ii,&pp)) { ++ if (! symTabIsMember(s_symTab,&p,&ii,&pp) ++ || MEM_FROM_PREVIOUS_BLOCK(pp) && IS_DEFINITION_OR_DECL_USAGE(usage)) { + pp = StackMemAlloc(S_symbol); + *pp = p; ++ setGlobalFileDepNames(id->name, pp, MEM_XX); + addSymbol(pp, s_symTab); + } + addCxReference(pp, &id->p, usage,s_noneFileIndex, s_noneFileIndex); +@@ -1032,6 +1057,7 @@ S_typeModifiers *crNewAnnonymeEnum(S_symbolList *enums) { + pp = StackMemAlloc(S_symbol); + FILL_symbolBits(&pp->b,0,0, 0,0,0, TypeEnum, StorageNone,0); + FILL_symbol(pp, "", "", s_noPos,pp->b,enums,enums, NULL); ++ setGlobalFileDepNames("", pp, MEM_XX); + pp->u.enums = enums; + return(crSimpleEnumType(pp,TypeEnum)); + } +-- +2.18.0 + diff --git a/0014-Make-include-file-option-processing-file-as-input.patch b/0014-Make-include-file-option-processing-file-as-input.patch new file mode 100644 index 000000000000..ce273685b371 --- /dev/null +++ b/0014-Make-include-file-option-processing-file-as-input.patch @@ -0,0 +1,111 @@ +From 829066d0befb18c484f2562ddf2299f97e623909 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Fri, 4 Aug 2017 02:34:56 +0300 +Subject: [PATCH 14/33] Make -include <file> option processing <file> as input + before processing the regular C input file + +--- + src/globals.c | 1 + + src/main.c | 23 ++++++++++++++++++++--- + src/proto.h | 1 + + 3 files changed, 22 insertions(+), 3 deletions(-) + +diff --git a/src/globals.c b/src/globals.c +index 777ba1e..b87dac0 100644 +--- a/src/globals.c ++++ b/src/globals.c +@@ -312,6 +312,7 @@ S_options s_initOpt = { + 0, // comment moving level + NULL, // prune name + NULL, // input files ++ NULL, // include files + RC_ZERO, // continue refactoring + 0, // completion case sensitive + NULL, // xrefrc +diff --git a/src/main.c b/src/main.c +index 46d0d29..3ef299d 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -54,6 +54,7 @@ static void usage(char *s) { + fprintf(stdout,"\t-javadocavailable=<packs> - packages for which javadoc is available\n"); + fprintf(stdout,"\t-p <prj> - read options from <prj> section\n"); + fprintf(stdout,"\t-I <dir> - search for includes in <dir>\n"); ++ fprintf(stdout,"\t-include <file> - process <file> as input before processing the regular C input file\n"); + fprintf(stdout,"\t-D<mac>[=<body>] - define macro <mac> with body <body>\n"); + fprintf(stdout,"\t-packages - allow packages as input files\n"); + fprintf(stdout,"\t-sourcepath <path> - set java sources paths\n"); +@@ -757,7 +758,14 @@ static int processIOption(int *ii, int argc, char **argv) { + mainAddStringListOption(&s_opt.includeDirs, argv[i]+2); + } + else if (strcmp(argv[i],"-include")==0) { +- i = mainHandleIncludeOption(argc, argv, i); ++ /* process file as if #include "file" */ ++ i++; ++ if (i >= argc) { ++ sprintf(tmpBuff,"file name expected after -include\n"); ++ error(ERR_ST,tmpBuff); ++ usage(argv[0]); ++ } ++ mainAddStringListOption(&s_opt.includeFiles, argv[i]); + } + else return(0); + *ii = i; +@@ -2029,6 +2036,12 @@ static void fileTabInit() { + + /*///////////////////////// parsing /////////////////////////////////// */ + static void mainParseInputFile() { ++ S_stringList *ll; ++ if (s_language == LAN_C || s_language == LAN_CCC) { ++ for (ll=s_opt.includeFiles; ll!=NULL; ll=ll->next) { ++ openInclude('<', ll->d, 0); ++ } ++ } + if (s_language == LAN_JAVA) { + uniyylval = & s_yygstate->gyylval; + javayyparse(); +@@ -2321,7 +2334,7 @@ static void mainFileProcessingInitialisations( + struct stat dffstat; + char *fileName; + int lc; +- S_stringList *tmpIncludeDirs; ++ S_stringList *tmpIncludeDirs,*tmpIncludeFiles; + + fileName = s_input_file_name; + mainSetLanguage(fileName, outLanguage); +@@ -2379,10 +2392,13 @@ static void mainFileProcessingInitialisations( + reInitCwd(dffname, dffsect); + tmpIncludeDirs = s_opt.includeDirs; + s_opt.includeDirs = NULL; ++ tmpIncludeFiles = s_opt.includeFiles; ++ s_opt.includeFiles = NULL; + getAndProcessXrefrcOptions(dffname, dffsect, dffsect); + getAndProcessGccIncludeOptions(); + getAndProcessGccDefineOptions(); + LIST_APPEND(S_stringList, s_opt.includeDirs, tmpIncludeDirs); ++ LIST_APPEND(S_stringList, s_opt.includeFiles, tmpIncludeFiles); + if (s_opt.taskRegime != RegimeEditServer && s_input_file_name == NULL) { + *outInputIn = 0; + goto fini; +@@ -2516,6 +2532,7 @@ static void mainTotalTaskEntryInitialisations(int argc, char **argv) { + DPRINTF("Initialisations.\n"); + memset(&s_count, 0, sizeof(S_counters)); + s_opt.includeDirs = NULL; ++ s_opt.includeFiles = NULL; + SM_INIT(ftMemory); + FT_ALLOCC(s_fileTab.tab, MAX_FILES, struct fileItem *);\ + FILL_EXP_COMMAND();\ +diff --git a/src/proto.h b/src/proto.h +index c050502..94488b1 100644 +--- a/src/proto.h ++++ b/src/proto.h +@@ -1622,6 +1622,7 @@ struct options { + int commentMovingLevel; + S_stringList *pruneNames; + S_stringList *inputFiles; ++ S_stringList *includeFiles; + int continueRefactoring; + int completionCaseSensitive; + char *xrefrc; +-- +2.18.0 + diff --git a/0015-Parse-initializer-list-for-arrays-structs-unions.patch b/0015-Parse-initializer-list-for-arrays-structs-unions.patch new file mode 100644 index 000000000000..66f6878783cb --- /dev/null +++ b/0015-Parse-initializer-list-for-arrays-structs-unions.patch @@ -0,0 +1,759 @@ +From e068b65efabb3d78b88936cf660393f42b6f5c80 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Mon, 10 Apr 2017 09:30:05 +0300 +Subject: [PATCH 15/33] Parse initializer-list for arrays/structs/unions + +--- + src/cgram.y | 113 +++++++++++++++++++++++++++++++++++++----------- + src/extract.c | 2 +- + src/globals.c | 36 +++++++-------- + src/head.h | 2 +- + src/javagram.y | 10 ++--- + src/jsemact.c | 24 +++++----- + src/jslsemact.c | 20 ++++----- + src/proto.h | 7 ++- + src/semact.c | 33 +++++++++++++- + src/yaccgram.y | 94 ++++++++++++++++++++++++++++++++-------- + 10 files changed, 247 insertions(+), 94 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index e4c2474..d8e5ba9 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -260,6 +260,8 @@ + %type <bbidIdent> IDENTIFIER identifier struct_identifier enum_identifier + %type <bbidIdent> str_rec_identifier STRUCT UNION struct_or_union + %type <bbidIdent> user_defined_type TYPE_NAME ++%type <bbidIdent> designator designator_list ++%type <bbidlist> designation_opt initializer initializer_list initializer_list_opt eq_initializer_opt + %type <bbinteger> assignment_operator + %type <bbinteger> pointer CONSTANT _ncounter_ _nlabel_ _ngoto_ _nfork_ + %type <bbunsign> storage_class_specifier type_specifier1 +@@ -500,17 +502,19 @@ unary_operator + + cast_expr + : unary_expr /* { $$.d = $1.d; } */ +- | '(' type_name ')' cast_expr { +- $$.d.t = $2.d; ++ | '(' type_name ')' cast_expr { ++ $$.d.t = $2.d; + $$.d.r = $4.d.r; + } +- | '(' type_name ')' '{' initializer_list '}' { /* GNU-extension*/ +- $$.d.t = $2.d; ++ | '(' type_name ')' '{' initializer_list_opt '}' { /* GNU-extension*/ ++ $$.d.t = $2.d; + $$.d.r = NULL; ++ addInitializerRefs($2.d, $5.d); + } + | '(' type_name ')' '{' initializer_list ',' '}' { /* GNU-extension*/ +- $$.d.t = $2.d; ++ $$.d.t = $2.d; + $$.d.r = NULL; ++ addInitializerRefs($2.d, $5.d); + } + ; + +@@ -703,15 +707,15 @@ declaration + ; + + init_declarations +- : declaration_specifiers init_declarator { ++ : declaration_specifiers init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $2.d, StorageAuto,s_symTab); +- } eq_initializer_opt +- | init_declarations ',' init_declarator { ++ addNewDeclaration($1.d, $2.d, $3.d, StorageAuto, s_symTab); ++ } ++ | init_declarations ',' init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $3.d, StorageAuto,s_symTab); +- } eq_initializer_opt +- | error { ++ addNewDeclaration($1.d, $3.d, $4.d, StorageAuto, s_symTab); ++ } ++ | error { + /* $$.d = &s_errorSymbol; */ + $$.d = typeSpecifier2(&s_errorModifier); + } +@@ -831,8 +835,12 @@ asm_opt: + | ASM_KEYWORD '(' string_literales ')' + ; + +-eq_initializer_opt: +- | '=' initializer ++eq_initializer_opt: { ++ $$.d = NULL; ++ } ++ | '=' initializer { ++ $$.d = $2.d; ++ } + ; + + init_declarator +@@ -1346,22 +1354,75 @@ abstract_declarator2 + ; + + initializer +- : assignment_expr +- /* it is enclosed because on linux kernel it overflows memory */ +- | '{' initializer_list '}' +- | '{' initializer_list ',' '}' +- | error ++ : assignment_expr { ++ $$.d = NULL; ++ } ++ /* it is enclosed because on linux kernel it overflows memory */ ++ | '{' initializer_list_opt '}' { ++ $$.d = $2.d; ++ } ++ | '{' initializer_list ',' '}' { ++ $$.d = $2.d; ++ } ++ | error { ++ $$.d = NULL; ++ } ++ ; ++ ++initializer_list_opt: { ++ $$.d = NULL; ++ } ++ | initializer_list { ++ $$.d = $1.d; ++ } + ; + + initializer_list +- : Sv_tmp Start_block initializer Stop_block { ++ : Sv_tmp designation_opt initializer { ++ $$.d = $2.d; ++ if ($$.d!=NULL) $$.d->down = $3.d; + tmpWorkMemoryi = $1.d; + } +- | initializer_list ',' Sv_tmp Start_block initializer Stop_block { ++ | initializer_list ',' Sv_tmp designation_opt initializer { ++ LIST_APPEND(S_idIdentList, $1.d, $4.d); ++ if ($4.d!=NULL) $4.d->down = $5.d; + tmpWorkMemoryi = $3.d; + } + ; + ++designation_opt: { ++ $$.d = NULL; ++ } ++ | designator_list '=' { ++ $$.d = StackMemAlloc(S_idIdentList); ++ FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, NULL,NULL); ++ } ++ ; ++ ++designator_list ++ : designator { ++ $$.d = $1.d; ++ } ++ | designator_list designator { ++ LIST_APPEND(S_idIdent, $1.d, $2.d); ++ } ++ ; ++ ++designator ++ : '[' constant_expr ']' { ++ $$.d = StackMemAlloc(S_idIdent); ++ FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ } ++ | '[' constant_expr ELIPSIS constant_expr ']' { ++ $$.d = StackMemAlloc(S_idIdent); ++ FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ } ++ | '.' str_rec_identifier { ++ $$.d = StackMemAlloc(S_idIdent); ++ *($$.d) = *($2.d); ++ } ++ ; ++ + statement + : Sv_tmp labeled_statement { + tmpWorkMemoryi = $1.d; +@@ -1681,17 +1742,17 @@ external_definition + top_init_declarations + : declaration_specifiers init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $2.d, StorageExtern,s_symTab); ++ addNewDeclaration($1.d, $2.d, $3.d, StorageExtern,s_symTab); + } +- | init_declarator eq_initializer_opt { ++ | init_declarator eq_initializer_opt { + $$.d = & s_defaultIntDefinition; +- addNewDeclaration($$.d, $1.d, StorageExtern,s_symTab); ++ addNewDeclaration($$.d, $1.d, $2.d, StorageExtern,s_symTab); + } + | top_init_declarations ',' init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $3.d, StorageExtern,s_symTab); ++ addNewDeclaration($1.d, $3.d, $4.d, StorageExtern,s_symTab); + } +- | error { ++ | error { + /* $$.d = &s_errorSymbol; */ + $$.d = typeSpecifier2(&s_errorModifier); + } +diff --git a/src/extract.c b/src/extract.c +index 86bc8a9..8037f22 100644 +--- a/src/extract.c ++++ b/src/extract.c +@@ -41,7 +41,7 @@ void genInternalLabelReference(int counter, int usage) { + char ttt[TMP_STRING_SIZE]; + S_idIdent ll; + LOCAL_LABEL_NAME(ttt,counter); +- FILLF_idIdent(&ll, ttt, NULL, cFile.lb.cb.fileNumber, 0,0); ++ FILLF_idIdent(&ll, ttt, NULL, cFile.lb.cb.fileNumber, 0,0,NULL); + if (usage != UsageDefined) ll.p.line++; + // line == 0 or 1 , (hack to get definition first) + labelReference(&ll, usage); +diff --git a/src/globals.c b/src/globals.c +index b87dac0..94b2c21 100644 +--- a/src/globals.c ++++ b/src/globals.c +@@ -174,48 +174,48 @@ S_idIdent s_javaAnonymousClassName = {"{Anonymous}", NULL, -1,0,0}; + S_idIdent s_javaConstructorName = {"<init>", NULL, -1,0,0}; + + static S_idIdentList s_javaDefaultPackageNameBody[] = { +- {"", NULL, -1,0,0, "", TypePackage, NULL}, ++ {"", NULL, -1,0,0,NULL, "", TypePackage, NULL}, + }; + S_idIdentList *s_javaDefaultPackageName = s_javaDefaultPackageNameBody; + + static S_idIdentList s_javaLangNameBody[] = { +- {"lang", NULL, -1,0,0, "lang", TypePackage, &s_javaLangNameBody[1]}, +- {"java", NULL, -1,0,0, "java", TypePackage, NULL}, ++ {"lang", NULL, -1,0,0,NULL, "lang", TypePackage, &s_javaLangNameBody[1]}, ++ {"java", NULL, -1,0,0,NULL, "java", TypePackage, NULL}, + }; + S_idIdentList *s_javaLangName = s_javaLangNameBody; + + static S_idIdentList s_javaLangStringNameBody[] = { +- {"String", NULL, -1,0,0, "String", TypeStruct, &s_javaLangStringNameBody[1]}, +- {"lang", NULL, -1,0,0, "lang", TypePackage, &s_javaLangStringNameBody[2]}, +- {"java", NULL, -1,0,0, "java", TypePackage, NULL}, ++ {"String", NULL, -1,0,0,NULL, "String", TypeStruct, &s_javaLangStringNameBody[1]}, ++ {"lang", NULL, -1,0,0,NULL, "lang", TypePackage, &s_javaLangStringNameBody[2]}, ++ {"java", NULL, -1,0,0,NULL, "java", TypePackage, NULL}, + }; + S_idIdentList *s_javaLangStringName = s_javaLangStringNameBody; + + static S_idIdentList s_javaLangCloneableNameBody[] = { +- {"Cloneable", NULL, -1,0,0, "Cloneable", TypeStruct, &s_javaLangCloneableNameBody[1]}, +- {"lang", NULL, -1,0,0, "lang", TypePackage, &s_javaLangCloneableNameBody[2]}, +- {"java", NULL, -1,0,0, "java", TypePackage, NULL}, ++ {"Cloneable", NULL, -1,0,0,NULL, "Cloneable", TypeStruct, &s_javaLangCloneableNameBody[1]}, ++ {"lang", NULL, -1,0,0,NULL, "lang", TypePackage, &s_javaLangCloneableNameBody[2]}, ++ {"java", NULL, -1,0,0,NULL, "java", TypePackage, NULL}, + }; + S_idIdentList *s_javaLangCloneableName = s_javaLangCloneableNameBody; + + static S_idIdentList s_javaIoSerializableNameBody[] = { +- {"Serializable", NULL, -1,0,0, "Serializable", TypeStruct, &s_javaIoSerializableNameBody[1]}, +- {"io", NULL, -1,0,0, "io", TypePackage, &s_javaIoSerializableNameBody[2]}, +- {"java", NULL, -1,0,0, "java", TypePackage, NULL}, ++ {"Serializable", NULL, -1,0,0,NULL, "Serializable", TypeStruct, &s_javaIoSerializableNameBody[1]}, ++ {"io", NULL, -1,0,0,NULL, "io", TypePackage, &s_javaIoSerializableNameBody[2]}, ++ {"java", NULL, -1,0,0,NULL, "java", TypePackage, NULL}, + }; + S_idIdentList *s_javaIoSerializableName = s_javaIoSerializableNameBody; + + static S_idIdentList s_javaLangClassNameBody[] = { +- {"Class", NULL, -1,0,0, "Class", TypeStruct, &s_javaLangClassNameBody[1]}, +- {"lang", NULL, -1,0,0, "lang", TypePackage, &s_javaLangClassNameBody[2]}, +- {"java", NULL, -1,0,0, "java", TypePackage, NULL}, ++ {"Class", NULL, -1,0,0,NULL, "Class", TypeStruct, &s_javaLangClassNameBody[1]}, ++ {"lang", NULL, -1,0,0,NULL, "lang", TypePackage, &s_javaLangClassNameBody[2]}, ++ {"java", NULL, -1,0,0,NULL, "java", TypePackage, NULL}, + }; + S_idIdentList *s_javaLangClassName = s_javaLangClassNameBody; + + static S_idIdentList s_javaLangObjectNameBody[] = { +- {"Object", NULL, -1,0,0, "Object", TypeStruct, &s_javaLangObjectNameBody[1]}, +- {"lang", NULL, -1,0,0, "lang", TypePackage, &s_javaLangObjectNameBody[2]}, +- {"java", NULL, -1,0,0, "java", TypePackage, NULL}, ++ {"Object", NULL, -1,0,0,NULL, "Object", TypeStruct, &s_javaLangObjectNameBody[1]}, ++ {"lang", NULL, -1,0,0,NULL, "lang", TypePackage, &s_javaLangObjectNameBody[2]}, ++ {"java", NULL, -1,0,0,NULL, "java", TypePackage, NULL}, + }; + S_idIdentList *s_javaLangObjectName = s_javaLangObjectNameBody; + char *s_javaLangObjectLinkName="java/lang/Object"; +diff --git a/src/head.h b/src/head.h +index 4b6848c..62176a6 100644 +--- a/src/head.h ++++ b/src/head.h +@@ -467,7 +467,7 @@ + #define SET_IDENTIFIER_YYLVAL(name, symb, pos) {\ + uniyylval->bbidIdent.d = &s_yyIdentBuf[s_yyIdentBufi];\ + s_yyIdentBufi ++; s_yyIdentBufi %= (YYBUFFERED_ID_INDEX);\ +- FILL_idIdent(uniyylval->bbidIdent.d, name, symb, pos);\ ++ FILL_idIdent(uniyylval->bbidIdent.d, name, symb, pos, NULL);\ + yytext = name;\ + uniyylval->bbidIdent.b = pos;\ + uniyylval->bbidIdent.e = pos;\ +diff --git a/src/javagram.y b/src/javagram.y +index 60d79b6..6a15c75 100644 +--- a/src/javagram.y ++++ b/src/javagram.y +@@ -762,7 +762,7 @@ Name: + SimpleName: + IDENTIFIER { + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, NULL); ++ FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, NULL,NULL); + PropagateBornsIfRegularSyntaxPass($$, $1, $1); + } + ; +@@ -770,7 +770,7 @@ SimpleName: + QualifiedName: + Name '.' IDENTIFIER { + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$3.d, $3.d->name, TypeDefault, $1.d); ++ FILL_idIdentList($$.d, *$3.d, $3.d->name, TypeDefault, NULL,$1.d); + PropagateBornsIfRegularSyntaxPass($$, $1, $3); + } + ; +@@ -2336,7 +2336,7 @@ LocalVarDeclUntilInit: + Type VariableDeclaratorId { + if (RegularPass()) { + if (! SyntaxPassOnly()) { +- addNewDeclaration($1.d,$2.d,StorageAuto,s_javaStat->locals); ++ addNewDeclaration($1.d,$2.d,NULL,StorageAuto,s_javaStat->locals); + $$.d = $1.d; + } else { + PropagateBorns($$, $1, $2); +@@ -2346,7 +2346,7 @@ LocalVarDeclUntilInit: + | FINAL Type VariableDeclaratorId { + if (RegularPass()) { + if (! SyntaxPassOnly()) { +- addNewDeclaration($2.d,$3.d,StorageAuto,s_javaStat->locals); ++ addNewDeclaration($2.d,$3.d,NULL,StorageAuto,s_javaStat->locals); + $$.d = $2.d; + } else { + PropagateBorns($$, $1, $3); +@@ -2357,7 +2357,7 @@ LocalVarDeclUntilInit: + if (RegularPass()) { + if (! SyntaxPassOnly()) { + if ($1.d->b.symType != TypeError) { +- addNewDeclaration($1.d,$3.d,StorageAuto,s_javaStat->locals); ++ addNewDeclaration($1.d,$3.d,NULL,StorageAuto,s_javaStat->locals); + } + $$.d = $1.d; + } else { +diff --git a/src/jsemact.c b/src/jsemact.c +index f488e56..43e4ff9 100644 +--- a/src/jsemact.c ++++ b/src/jsemact.c +@@ -164,8 +164,8 @@ void javaAddNestedClassesAsTypeDefs(S_symbol *cc, S_idIdentList *oclassname, + nn = ss->nest[i].cl; + assert(nn); + //& XX_ALLOC(ll, S_idIdentList); +- FILL_idIdent(&ll.idi, nn->name, cc, s_noPos); +- FILL_idIdentList(&ll, ll.idi, nn->name,TypeStruct,oclassname); ++ FILL_idIdent(&ll.idi, nn->name, cc, s_noPos, NULL); ++ FILL_idIdentList(&ll, ll.idi, nn->name,TypeStruct,NULL,oclassname); + javaTypeSymbolDefinition(&ll, accessFlags, TYPE_ADD_YES); + } + } +@@ -1240,8 +1240,8 @@ static int javaNotFqtUsageCorrection(S_symbol *sym, int usage) { + packname[pplen] = 0; + + FILLF_idIdentList(&sname, packname, NULL, +- s_noPos.file, s_noPos.line, s_noPos.coll, +- packname, TypeExpression, NULL) ++ s_noPos.file, s_noPos.line, s_noPos.coll, NULL, ++ packname, TypeExpression, NULL, NULL) + rr = javaClassifySingleAmbigName(&sname,&localRfs,&str,&expr,&loref, + CLASS_TO_EXPR, UsageNone, NO_CX_REFS); + if (rr!=TypePackage) { +@@ -1936,7 +1936,7 @@ void javaAddMapedTypeName( + strncpy(ttt2, file, len2); + InternalCheck(len2+1 < MAX_FILE_NAME_SIZE); + ttt2[len2] = 0; +- FILLF_idIdentList(&dd2, ttt2,NULL,-1,0,0, ttt2,TypeStruct,packid); ++ FILLF_idIdentList(&dd2, ttt2,NULL,-1,0,0,NULL, ttt2,TypeStruct,NULL,packid); + memb = javaTypeSymbolDefinition(&dd2,ACC_DEFAULT, TYPE_ADD_YES); + DPRINTF3(":import type %s == %s\n", memb->name, memb->linkName); + } +@@ -1964,8 +1964,8 @@ S_typeModifiers *javaNestedNewType(S_symbol *sym, S_idIdent *thenew, + id = &idl->idi; + assert(sym && sym->linkName); + id2 = sym->linkName; +- FILLF_idIdentList(&d2, id2, sym, -1,0,0, id2, TypeStruct, NULL); +- FILL_idIdentList(&d1, *id, id->name, TypeStruct, &d2); ++ FILLF_idIdentList(&d2, id2, sym, -1,0,0,NULL, id2, TypeStruct, NULL, NULL); ++ FILL_idIdentList(&d1, *id, id->name, TypeStruct, NULL, &d2); + javaClassifyNameToNestedType(&d1, sym, UsageUsed, &str, &rr); + res = javaClassNameType(&d1); + } else { +@@ -2415,7 +2415,7 @@ S_typeModifiers *javaConstructorInvocation(S_symbol *clas, + erfs = javaCrErfsForConstructorInvocation(clas, pos); + if (erfs == NULL) return(&s_errorModifier); + if (erfs->s.baseClass != erfs->s.currClass) return(&s_errorModifier); +- FILL_idIdent(&name, clas->name, NULL, *pos); ++ FILL_idIdent(&name, clas->name, NULL, *pos, NULL); + res = javaMethodInvocation(&erfs->s, erfs->memb, &name, args,CONSTRUCTOR_INVOCATION,&s_noPos); + return(res); + } +@@ -2652,9 +2652,9 @@ struct freeTrail * newClassDefinitionBegin( S_idIdent *name, + //& innerNamesCorrect = (strcmp(nn->cl->name, name->name)==0); + //& assert(innerNamesCorrect); + dd = nn->cl; +- FILL_idIdent(&idi,dd->linkName, NULL, name->p); ++ FILL_idIdent(&idi,dd->linkName, NULL, name->p, NULL); + XX_ALLOC(p, S_idIdentList); +- FILL_idIdentList(p, idi, dd->linkName, TypeStruct, NULL); ++ FILL_idIdentList(p, idi, dd->linkName, TypeStruct, NULL,NULL); + ddd = javaAddType(p, accessFlags, & name->p); + assert(dd==ddd); + res = s_topBlock->trail; +@@ -2662,7 +2662,7 @@ struct freeTrail * newClassDefinitionBegin( S_idIdent *name, + } else { + /* probably base class */ + XX_ALLOC(p,S_idIdentList); +- FILL_idIdentList(p,*name,name->name,TypeStruct,s_javaStat->className); ++ FILL_idIdentList(p,*name,name->name,TypeStruct,NULL,s_javaStat->className); + dd = javaAddType(p, accessFlags, & name->p); + res = s_topBlock->trail; + assert(dd->b.symType == TypeStruct); +@@ -2684,7 +2684,7 @@ struct freeTrail * newAnonClassDefinitionBegin(S_idIdent *interfName) { + S_idIdentList *ll; + S_symbol *interf, *str; + XX_ALLOC(ll, S_idIdentList); +- FILL_idIdentList(ll, *interfName, interfName->name, TypeDefault, NULL); ++ FILL_idIdentList(ll, *interfName, interfName->name, TypeDefault, NULL,NULL); + javaClassifyToTypeName(ll,UsageUsed,&str, USELESS_FQT_REFS_ALLOWED); + interf = javaTypeNameDefinition(ll); + res = newClassDefinitionBegin(&s_javaAnonymousClassName, ACC_DEFAULT, +diff --git a/src/jslsemact.c b/src/jslsemact.c +index df1d0e1..6434f47 100644 +--- a/src/jslsemact.c ++++ b/src/jslsemact.c +@@ -91,7 +91,7 @@ S_symbol *jslTypeSymbolDefinition(char *ttt2, S_idIdentList *packid, + S_position *importPos; + + jslFillTypeSymbolItem( &sd, &ss, ttt2); +- FILLF_idIdentList(&dd2, ttt2,NULL,-1,0,0, ttt2,TypeStruct,packid); ++ FILLF_idIdentList(&dd2, ttt2,NULL,-1,0,0,NULL, ttt2,TypeStruct,NULL,packid); + javaCreateComposedName(NULL,&dd2,'/',NULL,fqtName,MAX_FILE_NAME_SIZE); + smemb = javaFQTypeSymbolDefinition(ttt2, fqtName); + //&fprintf(ccOut, "[jsl] jslTypeSymbolDefinition %s, %s, %s, %s\n", ttt2, fqtName, smemb->name, smemb->linkName); +@@ -130,7 +130,7 @@ S_symbol *jslTypeSymbolUsage(char *ttt2, S_idIdentList *packid) { + smemb = memb->d; + return(smemb); + } +- FILLF_idIdentList(&dd2, ttt2,NULL,-1,0,0, ttt2,TypeStruct,packid); ++ FILLF_idIdentList(&dd2, ttt2,NULL,-1,0,0,NULL, ttt2,TypeStruct,NULL,packid); + javaCreateComposedName(NULL,&dd2,'/',NULL,fqtName,MAX_FILE_NAME_SIZE); + smemb = javaFQTypeSymbolDefinition(ttt2, fqtName); + return(smemb); +@@ -440,9 +440,9 @@ void jslAddNestedClassesToJslTypeTab( S_symbol *str, int order) { + for(i=0; i<ss->nnested; i++) { + //&fprintf(dumpOut,"checking %s %s %d %d\n", ss->nest[i].cl->name, ss->nest[i].cl->linkName,ss->nest[i].membFlag, jslRecordAccessible(str, ss->nest[i].cl, ss->nest[i].accFlags)); + if (ss->nest[i].membFlag && jslRecordAccessible(str, ss->nest[i].cl, ss->nest[i].accFlags)) { +- FILL_idIdent(&ocid, str->linkName, NULL, s_noPos); ++ FILL_idIdent(&ocid, str->linkName, NULL, s_noPos, NULL); + FILL_idIdentList(&oclassid, ocid, str->linkName, +- TypeStruct, NULL); ++ TypeStruct, NULL,NULL); + //&fprintf(dumpOut,"adding %s %s\n", ss->nest[i].cl->name, ss->nest[i].cl->linkName); + jslTypeSymbolDefinition(ss->nest[i].cl->name, &oclassid, + TYPE_ADD_YES, order, 0); +@@ -488,9 +488,9 @@ void jslNewClassDefinitionBegin(S_idIdent *name, + sprintf(tttn, "%d", s_jsl->classStat->functionInnerCounter); + sprintf(ttt, "%s", inname->name); + FILLF_idIdentList(&mntmp, tttn, NULL, +- s_noPos.file, s_noPos.line, s_noPos.coll, ++ s_noPos.file, s_noPos.line, s_noPos.coll, NULL, + tttn, +- TypeStruct, s_jsl->classStat->className); ++ TypeStruct, NULL, s_jsl->classStat->className); + // this is a very special reason why to do TYPE_ADD_YES here, + // because method nested class will not be added as class nested + // at the end of this function +@@ -569,9 +569,9 @@ void jslNewClassDefinitionBegin(S_idIdent *name, + stackMemoryBlockStart(); + XX_ALLOC(ill, S_idIdentList); + FILLF_idIdentList(ill, cc->name, inname->sd, +- inname->p.file, inname->p.line, inname->p.coll, +- cc->name,TypeStruct, +- s_jsl->classStat->className); ++ inname->p.file, inname->p.line, inname->p.coll, NULL, ++ cc->name, TypeStruct, ++ NULL, s_jsl->classStat->className); + XX_ALLOC(nss, S_jslClassStat); + FILL_jslClassStat(nss, ill, cc, s_jsl->classStat->thisPackage, + 0, 0, s_jsl->classStat); +@@ -620,7 +620,7 @@ void jslNewAnonClassDefinitionBegin(S_idIdent *interfName) { + S_idIdentList ll; + S_symbol *interf,*str; + //& XX_ALLOC(ll, S_idIdentList); +- FILL_idIdentList(&ll, *interfName, interfName->name, TypeDefault, NULL); ++ FILL_idIdentList(&ll, *interfName, interfName->name, TypeDefault, NULL,NULL); + jslClassifyAmbiguousTypeName(&ll, &str); + interf = jslTypeNameDefinition(&ll); + jslNewClassDefinitionBegin(&s_javaAnonymousClassName, ACC_DEFAULT, +diff --git a/src/proto.h b/src/proto.h +index 94488b1..0d52b1c 100644 +--- a/src/proto.h ++++ b/src/proto.h +@@ -698,6 +698,7 @@ struct idIdent { + char *name; + S_symbol *sd; /* if yet in symbol table */ + S_position p; /* position */ ++ S_idIdent *next; + }; + + struct freeTrail { +@@ -1134,9 +1135,10 @@ struct javaStat { + /* java composed names */ + + struct idIdentList { +- S_idIdent idi; ++ S_idIdent idi; + char *fname; /* fqt name for java */ + uchar nameType; /* type of name segment for java */ ++ S_idIdentList *down; + S_idIdentList *next; + }; + +@@ -2272,8 +2274,9 @@ int findStrRecordSym C_ARG(( S_recFindStr *ss, + )); + S_symbol *addNewSymbolDef C_ARG((S_symbol *p, unsigned storage, S_symTab *tab, int usage)); + S_symbol *addNewCopyOfSymbolDef C_ARG((S_symbol *def, unsigned defaultStorage)); +-S_symbol *addNewDeclaration C_ARG((S_symbol *btype, S_symbol *decl, ++S_symbol *addNewDeclaration C_ARG((S_symbol *btype, S_symbol *decl, S_idIdentList *idl, + unsigned storage, S_symTab *tab)); ++void addInitializerRefs(S_typeModifiers *t, S_idIdentList *idl); + int styyerror C_ARG((char *s)); + int styyErrorRecovery C_ARG(()); + void setToNull C_ARG((void *p)); +diff --git a/src/semact.c b/src/semact.c +index b406879..cb3f623 100644 +--- a/src/semact.c ++++ b/src/semact.c +@@ -588,9 +588,39 @@ S_symbol *addNewCopyOfSymbolDef(S_symbol *def, unsigned storage) { + return(p); + } + ++void addInitializerRefs( ++ S_typeModifiers *t, ++ S_idIdentList *idl ++ ) { ++ S_idIdentList *ll; ++ S_idIdent* id; ++ S_typeModifiers *tt; ++ S_reference *ref; ++ S_symbol *rec; ++ for(ll=idl; ll!=NULL; ll=ll->next) { ++ tt = t; ++ rec = NULL; ++ for (id = &ll->idi; id!=NULL; id=id->next) { ++ if (tt->m == TypeArray) { ++ tt = tt->next; ++ continue; ++ } ++ if (tt->m != TypeStruct && tt->m != TypeUnion) return; ++ ref = findStrRecordFromType(tt, id, &rec, CLASS_TO_ANY); ++ if (NULL == ref) return; ++ assert(rec); ++ tt = rec->u.type; ++ } ++ if (ll->down!=NULL && rec!=NULL) { ++ addInitializerRefs(rec->u.type, ll->down); ++ } ++ } ++} ++ + S_symbol *addNewDeclaration( + S_symbol *btype, +- S_symbol *decl, ++ S_symbol *decl, ++ S_idIdentList *idl, + unsigned storage, + S_symTab *tab + ) { +@@ -605,6 +635,7 @@ S_symbol *addNewDeclaration( + if (decl->u.type->m == TypeFunction) usage = UsageDeclared; + else if (decl->b.storage == StorageExtern) usage = UsageDeclared; + addNewSymbolDef(decl, storage, tab, usage); ++ addInitializerRefs(decl->u.type, idl); + return(decl); + } + +diff --git a/src/yaccgram.y b/src/yaccgram.y +index 7e73ef2..87b406c 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -267,6 +267,8 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + %type <bbidIdent> str_rec_identifier STRUCT UNION struct_or_union + %type <bbidIdent> user_defined_type TYPE_NAME lexem + %type <bbinteger> pointer CONSTANT rule_body ++%type <bbidIdent> designator designator_list ++%type <bbidlist> designation_opt initializer initializer_list initializer_list_opt eq_initializer_opt + %type <bbunsign> storage_class_specifier type_specifier1 + %type <bbunsign> type_modality_specifier Sv_tmp + %type <bbsymbol> init_declarator declarator declarator2 struct_declarator +@@ -364,7 +366,7 @@ symbol_to_type_seq: + ss->u.type = NULL; + addYaccSymbolReference($2.d,UsageDeclared); + if (l_currentType!=NULL) { +- addNewDeclaration(l_currentType, ss, StorageAuto,s_symTab); ++ addNewDeclaration(l_currentType, ss, NULL, StorageAuto, s_symTab); + } + } + ; +@@ -658,17 +660,19 @@ unary_operator + + cast_expr + : unary_expr /* { $$.d = $1.d; } */ +- | '(' type_name ')' cast_expr { +- $$.d.t = $2.d; ++ | '(' type_name ')' cast_expr { ++ $$.d.t = $2.d; + $$.d.r = $4.d.r; + } +- | '(' type_name ')' '{' initializer_list '}' { /* GNU-extension*/ +- $$.d.t = $2.d; ++ | '(' type_name ')' '{' initializer_list_opt '}' { /* GNU-extension*/ ++ $$.d.t = $2.d; + $$.d.r = NULL; ++ addInitializerRefs($2.d, $5.d); + } + | '(' type_name ')' '{' initializer_list ',' '}' { /* GNU-extension*/ +- $$.d.t = $2.d; ++ $$.d.t = $2.d; + $$.d.r = NULL; ++ addInitializerRefs($2.d, $5.d); + } + ; + +@@ -844,11 +848,11 @@ declaration + init_declarations + : declaration_specifiers init_declarator { + $$.d = $1.d; +- addNewDeclaration($1.d, $2.d, StorageAuto,s_symTab); ++ addNewDeclaration($1.d, $2.d, NULL, StorageAuto,s_symTab); + } + | init_declarations ',' init_declarator { + $$.d = $1.d; +- addNewDeclaration($1.d, $3.d, StorageAuto,s_symTab); ++ addNewDeclaration($1.d, $3.d, NULL, StorageAuto,s_symTab); + } + | error { + /*$$.d = &s_errorSymbol;*/ +@@ -1435,19 +1439,73 @@ abstract_declarator2 + ; + + initializer +- : assignment_expr +- | '{' Start_block initializer_list Stop_block '}' +- | '{' Start_block initializer_list ',' Stop_block '}' ++ : assignment_expr { ++ $$.d = NULL; ++ } ++ /* it is enclosed because on linux kernel it overflows memory */ ++ | '{' initializer_list_opt '}' { ++ $$.d = $2.d; ++ } ++ | '{' initializer_list ',' '}' { ++ $$.d = $2.d; ++ } ++ | error { ++ $$.d = NULL; ++ } ++ ; ++ ++initializer_list_opt: { ++ $$.d = NULL; ++ } ++ | initializer_list { ++ $$.d = $1.d; ++ } + ; + + initializer_list +- : Sv_tmp initializer { ++ : Sv_tmp designation_opt initializer { ++ $$.d = $2.d; ++ if ($$.d!=NULL) $$.d->down = $3.d; + tmpWorkMemoryi = $1.d; + } +- | initializer_list ',' Sv_tmp initializer { ++ | initializer_list ',' Sv_tmp designation_opt initializer { ++ LIST_APPEND(S_idIdentList, $1.d, $4.d); ++ if ($4.d!=NULL) $4.d->down = $5.d; + tmpWorkMemoryi = $3.d; + } +- | error ++ ; ++ ++designation_opt: { ++ $$.d = NULL; ++ } ++ | designator_list '=' { ++ $$.d = StackMemAlloc(S_idIdentList); ++ FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, NULL,NULL); ++ } ++ ; ++ ++designator_list ++ : designator { ++ $$.d = $1.d; ++ } ++ | designator_list designator { ++ LIST_APPEND(S_idIdent, $1.d, $2.d); ++ } ++ ; ++ ++designator ++ : '[' constant_expr ']' { ++ $$.d = StackMemAlloc(S_idIdent); ++ FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ } ++ | '[' constant_expr ELIPSIS constant_expr ']' { ++ $$.d = StackMemAlloc(S_idIdent); ++ FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ } ++ | '.' str_rec_identifier { ++ $$.d = StackMemAlloc(S_idIdent); ++ *($$.d) = *($2.d); ++ } + ; + + statement +@@ -1609,15 +1667,15 @@ external_definition + top_init_declarations + : declaration_specifiers init_declarator { + $$.d = $1.d; +- addNewDeclaration($1.d, $2.d, StorageExtern,s_symTab); ++ addNewDeclaration($1.d, $2.d, NULL, StorageExtern,s_symTab); + } + | init_declarator { + $$.d = & s_defaultIntDefinition; +- addNewDeclaration($$.d, $1.d, StorageExtern,s_symTab); ++ addNewDeclaration($$.d, $1.d, NULL, StorageExtern,s_symTab); + } + | top_init_declarations ',' init_declarator { + $$.d = $1.d; +- addNewDeclaration($1.d, $3.d, StorageExtern,s_symTab); ++ addNewDeclaration($1.d, $3.d, NULL, StorageExtern,s_symTab); + } + | error { + /*$$.d = &s_errorSymbol;*/ +@@ -1730,7 +1788,7 @@ static void addRuleLocalVariable(S_idIdent *name, int order) { + FILL_symbolBits(&ss->b,0,0,0,0,0,TypeDefault,StorageAuto,0); + FILL_symbol(ss,nn,nn,name->p,ss->b,type,NULL,NULL); + ss->pos.coll ++ ; // to avoid ambiguity of NonTerminal <-> $$.d +- addNewDeclaration(p, ss, StorageAuto, s_symTab); ++ addNewDeclaration(p, ss, NULL, StorageAuto, s_symTab); + } + } + } +-- +2.18.0 + diff --git a/0016-Parse-empty-fields-in-struct-declarations.patch b/0016-Parse-empty-fields-in-struct-declarations.patch new file mode 100644 index 000000000000..bd930a88fd5e --- /dev/null +++ b/0016-Parse-empty-fields-in-struct-declarations.patch @@ -0,0 +1,47 @@ +From 83d15c9bebf3c95cd817015f74f2e9fc96b6d0ec Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Sun, 18 Jun 2017 18:47:25 +0300 +Subject: [PATCH 16/33] Parse empty fields in struct declarations + +--- + src/cgram.y | 6 ++++-- + src/yaccgram.y | 6 ++++-- + 2 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index d8e5ba9..601df1e 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -1141,8 +1141,10 @@ type_specifier_list + ; + */ + +-type_specifier_list +- : type_mod_specifier_list /* { $$.d = $1.d; } */ ++type_specifier_list: { /* gcc extension allow empty field */ ++ $$.d = crEmptyField(); ++ } ++ | type_mod_specifier_list /* { $$.d = $1.d; } */ + | type_specifier_list0 /* { $$.d = $1.d; } */ + ; + +diff --git a/src/yaccgram.y b/src/yaccgram.y +index 87b406c..a6ca5d6 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -1235,8 +1235,10 @@ type_specifier_list + ; + */ + +-type_specifier_list +- : type_mod_specifier_list /* { $$.d = $1.d; } */ ++type_specifier_list: { /* gcc extension allow empty field */ ++ $$.d = crEmptyField(); ++ } ++ | type_mod_specifier_list /* { $$.d = $1.d; } */ + | type_specifier_list0 /* { $$.d = $1.d; } */ + ; + +-- +2.18.0 + diff --git a/0017-Parse-asm-statement.patch b/0017-Parse-asm-statement.patch new file mode 100644 index 000000000000..d3b81b5c1ace --- /dev/null +++ b/0017-Parse-asm-statement.patch @@ -0,0 +1,36 @@ +From 52ef15b2c7b4052ca5de1f338e83a79b884a5f9b Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Mon, 5 Jun 2017 17:24:08 +0300 +Subject: [PATCH 17/33] Parse asm statement + +--- + src/cgram.y | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index 601df1e..3660987 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -1642,11 +1642,15 @@ _bef_: { + /* ****************** following is some gcc asm support ************ */ + /* it is not exactly as in gcc, but I hope it is suf. general */ + ++gcc_asm_symbolic_name_opt: ++ | '[' IDENTIFIER ']' ++ ; ++ + gcc_asm_item_opt: +- | IDENTIFIER +- | string_literales +- | IDENTIFIER '(' expr ')' +- | string_literales '(' expr ')' ++ | gcc_asm_symbolic_name_opt IDENTIFIER ++ | gcc_asm_symbolic_name_opt IDENTIFIER '(' expr ')' ++ | gcc_asm_symbolic_name_opt string_literales ++ | gcc_asm_symbolic_name_opt string_literales '(' expr ')' + ; + + gcc_asm_item_list: +-- +2.18.0 + diff --git a/0018-Parse-ranges-in-case-labeled-statement.patch b/0018-Parse-ranges-in-case-labeled-statement.patch new file mode 100644 index 000000000000..bf18c2f5a69c --- /dev/null +++ b/0018-Parse-ranges-in-case-labeled-statement.patch @@ -0,0 +1,39 @@ +From b31854f0fe28337462ba4078ed5d769247a82930 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Mon, 5 Jun 2017 17:44:09 +0300 +Subject: [PATCH 18/33] Parse ranges in case labeled statement + +--- + src/cgram.y | 3 +++ + src/yaccgram.y | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/src/cgram.y b/src/cgram.y +index 3660987..bf44655 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -1457,6 +1457,9 @@ label: + | CASE constant_expr ':' { + GenSwitchCaseFork(0); + } ++ | CASE constant_expr ELIPSIS constant_expr ':' { ++ GenSwitchCaseFork(0); ++ } + | DEFAULT ':' { + GenSwitchCaseFork(0); + } +diff --git a/src/yaccgram.y b/src/yaccgram.y +index a6ca5d6..a374355 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -1535,6 +1535,7 @@ statement + labeled_statement + : label_def_name ':' statement + | CASE constant_expr ':' statement ++ | CASE constant_expr ELIPSIS constant_expr ':' statement + | DEFAULT ':' statement + ; + +-- +2.18.0 + diff --git a/0019-Add-missed-C-keywords.patch b/0019-Add-missed-C-keywords.patch new file mode 100644 index 000000000000..6d0ad6e28391 --- /dev/null +++ b/0019-Add-missed-C-keywords.patch @@ -0,0 +1,319 @@ +From 9aeae94b69b08c076f3d3ff37835e1fba7214a59 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Fri, 5 May 2017 22:56:33 +0300 +Subject: [PATCH 19/33] Add missed C keywords + +squash! Add missed C keywords + +squash! Add missed C keywords + +squash! Add missed C keywords +--- + src/cgram.y | 33 ++++++++++++++++++++++++--------- + src/cxref.c | 1 + + src/globals.c | 14 +++++++++----- + src/javagram.y | 2 +- + src/proto.h | 3 ++- + src/yaccgram.y | 35 +++++++++++++++++++++++++---------- + 6 files changed, 62 insertions(+), 26 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index bf44655..58020dd 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -108,7 +108,7 @@ + + /* c-special */ + %token TYPEDEF EXTERN AUTO REGISTER SIGNED UNSIGNED STRUCT UNION ENUM +-%token SIZEOF ++%token SIZEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN + /* hmm */ + %token ANONYME_MOD + +@@ -783,6 +783,9 @@ declaration_specifiers0 + $$.d = $1.d; + $$.d->b.storage = $2.d; + } ++ | declaration_specifiers0 function_specifier { ++ $$.d = $1.d; ++ } + | COMPL_TYPE_NAME { + assert(0); + } +@@ -806,6 +809,12 @@ declaration_modality_specifiers + | declaration_modality_specifiers type_modality_specifier { + declTypeSpecifier1($1.d, $2.d); + } ++ | function_specifier { ++ $$.d = typeSpecifier1(TypeDefault); ++ } ++ | declaration_modality_specifiers function_specifier { ++ $$.d = $1.d; ++ } + ; + + /*& // an experiment +@@ -854,19 +863,19 @@ init_declarator + */ + + storage_class_specifier +- : TYPEDEF { $$.d = StorageTypedef; } +- | EXTERN { $$.d = StorageExtern; } +- | STATIC { $$.d = StorageStatic; } +- | AUTO { $$.d = StorageAuto; } +- | REGISTER { $$.d = StorageAuto; } +-/* +- | INLINE { $$.d = StorageStatic; } +-*/ ++ : TYPEDEF { $$.d = StorageTypedef; } ++ | EXTERN { $$.d = StorageExtern; } ++ | STATIC { $$.d = StorageStatic; } ++ | _THREADLOCAL { $$.d = StorageThreadLocal; } ++ | AUTO { $$.d = StorageAuto; } ++ | REGISTER { $$.d = StorageAuto; } + ; + + type_modality_specifier + : CONST { $$.d = TypeDefault; } ++ | RESTRICT { $$.d = TypeDefault; } + | VOLATILE { $$.d = TypeDefault; } ++ | _ATOMIC { $$.d = TypeDefault; } + | ANONYME_MOD { $$.d = TypeDefault; } + ; + +@@ -884,6 +893,7 @@ type_specifier1 + | FLOAT { $$.d = TypeFloat; } + | DOUBLE { $$.d = TypeDouble; } + | VOID { $$.d = TypeVoid; } ++ | _BOOL { $$.d = TypeBoolean; } + ; + + type_specifier2 +@@ -891,6 +901,11 @@ type_specifier2 + | enum_specifier /* { $$.d = $1.d; } */ + ; + ++function_specifier ++ : INLINE ++ | _NORETURN ++ ; ++ + struct_or_union_specifier + : struct_or_union struct_identifier { + int usage; +diff --git a/src/cxref.c b/src/cxref.c +index de9c634..2e91f37 100644 +--- a/src/cxref.c ++++ b/src/cxref.c +@@ -300,6 +300,7 @@ static void getSymbolCxrefCategories( + || p->b.storage==StorageMethod + || p->b.storage==StorageConstructor + || p->b.storage==StorageStatic ++ || p->b.storage==StorageThreadLocal + ) { + if (p->linkName[0]==' ' && p->linkName[1]==' ') { + // a special symbol local linkname +diff --git a/src/globals.c b/src/globals.c +index 94b2c21..4df9006 100644 +--- a/src/globals.c ++++ b/src/globals.c +@@ -527,10 +527,11 @@ S_typeModificationsInit s_typeModificationsInit[] = { + }; + + S_tokenNameIni s_tokenNameIniTab[] = { +- {"asm", ASM_KEYWORD ,LAN_CCC}, ++ {"asm", ASM_KEYWORD ,LAN_C | LAN_YACC | LAN_CCC}, + {"auto", AUTO ,LAN_C | LAN_YACC | LAN_CCC}, + {"enum", ENUM ,LAN_C | LAN_YACC | LAN_CCC}, + {"extern", EXTERN ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"inline", INLINE ,LAN_C | LAN_YACC | LAN_CCC}, + {"register", REGISTER ,LAN_C | LAN_YACC | LAN_CCC}, + {"signed", SIGNED ,LAN_C | LAN_YACC | LAN_CCC}, + {"sizeof", SIZEOF ,LAN_C | LAN_YACC | LAN_CCC}, +@@ -578,7 +579,6 @@ S_tokenNameIni s_tokenNameIniTab[] = { + {"dynamic_cast", DYNAMIC_CAST ,LAN_CCC}, + {"explicit", EXPLICIT ,LAN_CCC}, + {"friend", FRIEND ,LAN_CCC}, +- {"inline", INLINE ,LAN_CCC}, + {"mutable", MUTABLE ,LAN_CCC}, + {"namespace", NAMESPACE ,LAN_CCC}, + {"operator", OPERATOR ,LAN_CCC}, +@@ -614,6 +614,12 @@ S_tokenNameIni s_tokenNameIniTab[] = { + {"volatile", VOLATILE ,LAN_C | LAN_YACC | LAN_CCC | LAN_JAVA}, + {"while", WHILE ,LAN_C | LAN_YACC | LAN_CCC | LAN_JAVA}, + ++ {"restrict", RESTRICT ,LAN_C}, ++ {"_Atomic", _ATOMIC ,LAN_C}, ++ {"_Bool", _BOOL ,LAN_C}, ++ {"_Noreturn", _NORETURN ,LAN_C}, ++ {"_Thread_local", _THREADLOCAL ,LAN_C}, ++ + /* + {"token", TOKEN ,LAN_YACC}, + {"type", TYPE ,LAN_YACC}, +@@ -707,12 +713,10 @@ S_tokenNameIni s_tokenNameIniTab2[] = { + {"__const__", CONST ,LAN_C | LAN_YACC | LAN_CCC}, + {"__signed", SIGNED ,LAN_C | LAN_YACC | LAN_CCC}, + {"__signed__", SIGNED ,LAN_C | LAN_YACC | LAN_CCC}, +-//& {"inline", ANONYME_MOD ,LAN_C | LAN_YACC }, + {"__inline", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__inline__", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__volatile", VOLATILE ,LAN_C | LAN_YACC | LAN_CCC}, + {"__volatile__", VOLATILE ,LAN_C | LAN_YACC | LAN_CCC}, +-//& {"asm", ASM_KEYWORD ,LAN_C }, + {"__asm", ASM_KEYWORD ,LAN_C | LAN_CCC}, + {"__asm__", ASM_KEYWORD ,LAN_C | LAN_CCC}, + {"__label__", LABEL ,LAN_C | LAN_CCC}, +@@ -858,6 +862,7 @@ int s_preCrTypesIniTab[] = { + TypeLongSignedInt , + TypeFloat , + TypeDouble , ++ TypeBoolean , + TypeVoid , + TypeError , + TypeAnonymeField , +@@ -874,7 +879,6 @@ int s_preCrTypesIniTab[] = { + TypeByte, + TypeShort, + TypeLong, +- TypeBoolean, + TypeNull, + /* C++ */ + TypeWchar_t, +diff --git a/src/javagram.y b/src/javagram.y +index 6a15c75..4dcf023 100644 +--- a/src/javagram.y ++++ b/src/javagram.y +@@ -156,7 +156,7 @@ + + /* c-special */ + %token TYPEDEF EXTERN AUTO REGISTER SIGNED UNSIGNED STRUCT UNION ENUM +-%token SIZEOF ++%token SIZEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN + /* hmm */ + %token ANONYME_MOD + +diff --git a/src/proto.h b/src/proto.h +index 0d52b1c..02b08e6 100644 +--- a/src/proto.h ++++ b/src/proto.h +@@ -501,6 +501,7 @@ enum storages { + StorageExtern, + StorageConstant, /* enumerator definition */ + StorageStatic, ++ StorageThreadLocal, + StorageTypedef, + StorageMutable, + StorageRegister, +@@ -530,6 +531,7 @@ enum types { + TypeLongSignedInt , + TypeFloat , + TypeDouble , ++ TypeBoolean, + TypeStruct, + TypeUnion, + TypeEnum , +@@ -558,7 +560,6 @@ enum types { + TypeByte, + TypeShort, + TypeLong, +- TypeBoolean, + TypeNull, + TypeOverloadedFunction, + TypeReserve7, +diff --git a/src/yaccgram.y b/src/yaccgram.y +index a374355..0bca507 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -118,7 +118,7 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + + /* c-special */ + %token TYPEDEF EXTERN AUTO REGISTER SIGNED UNSIGNED STRUCT UNION ENUM +-%token SIZEOF ++%token SIZEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN + /* hmm */ + %token ANONYME_MOD + +@@ -482,7 +482,7 @@ any_token_not_perc_par: + | DOUBLE | ELSE | FLOAT | FOR | GOTO | IF | INT | LONG | RETURN | SHORT + | SWITCH | VOID | VOLATILE | WHILE + | TYPEDEF | EXTERN | AUTO | REGISTER | SIGNED | UNSIGNED | STRUCT | UNION +- | ENUM | SIZEOF ++ | ENUM | SIZEOF | RESTRICT | _ATOMIC | _BOOL | _THREADLOCAL | _NORETURN + | ANONYME_MOD | TOKEN + | ABSTRACT | BOOLEAN | BYTE | CATCH | CLASS | EXTENDS | FINAL | FINALLY + | IMPLEMENTS | IMPORT | INSTANCEOF | INTERFACE | NATIVE | NEW +@@ -922,6 +922,9 @@ declaration_specifiers0 + $$.d = $1.d; + $$.d->b.storage = $2.d; + } ++ | declaration_specifiers0 function_specifier { ++ $$.d = $1.d; ++ } + | COMPL_TYPE_NAME { + assert(0); + } +@@ -950,6 +953,12 @@ declaration_modality_specifiers + | declaration_modality_specifiers type_modality_specifier { + declTypeSpecifier1($1.d, $2.d); + } ++ | function_specifier { ++ $$.d = typeSpecifier1(TypeDefault); ++ } ++ | declaration_modality_specifiers function_specifier { ++ $$.d = $1.d; ++ } + ; + + init_declarator +@@ -958,19 +967,19 @@ init_declarator + ; + + storage_class_specifier +- : TYPEDEF { $$.d = StorageTypedef; } +- | EXTERN { $$.d = StorageExtern; } +- | STATIC { $$.d = StorageStatic; } +- | AUTO { $$.d = StorageAuto; } +- | REGISTER { $$.d = StorageAuto; } +-/* +- | INLINE { $$.d = StorageStatic; } +-*/ ++ : TYPEDEF { $$.d = StorageTypedef; } ++ | EXTERN { $$.d = StorageExtern; } ++ | STATIC { $$.d = StorageStatic; } ++ | _THREADLOCAL { $$.d = StorageThreadLocal; } ++ | AUTO { $$.d = StorageAuto; } ++ | REGISTER { $$.d = StorageAuto; } + ; + + type_modality_specifier + : CONST { $$.d = TypeDefault; } ++ | RESTRICT { $$.d = TypeDefault; } + | VOLATILE { $$.d = TypeDefault; } ++ | _ATOMIC { $$.d = TypeDefault; } + | ANONYME_MOD { $$.d = TypeDefault; } + ; + +@@ -984,6 +993,7 @@ type_specifier1 + | FLOAT { $$.d = TypeFloat; } + | DOUBLE { $$.d = TypeDouble; } + | VOID { $$.d = TypeVoid; } ++ | _BOOL { $$.d = TypeBoolean; } + ; + + type_specifier2 +@@ -991,6 +1001,11 @@ type_specifier2 + | enum_specifier /* { $$.d = $1.d; } */ + ; + ++function_specifier ++ : INLINE ++ | _NORETURN ++ ; ++ + struct_or_union_specifier + : struct_or_union struct_identifier { + $$.d = simpleStrUnionSpecifier($1.d, $2.d, UsageUsed); +-- +2.18.0 + diff --git a/0020-Add-GCC-keyword-extensions.patch b/0020-Add-GCC-keyword-extensions.patch new file mode 100644 index 000000000000..4b8ce432ce68 --- /dev/null +++ b/0020-Add-GCC-keyword-extensions.patch @@ -0,0 +1,33 @@ +From ec1f9bc97176b5e707673d5a49601c833df3f825 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Tue, 13 Jun 2017 15:04:51 +0300 +Subject: [PATCH 20/33] Add GCC keyword extensions + +--- + src/globals.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/globals.c b/src/globals.c +index 4df9006..ade4b4b 100644 +--- a/src/globals.c ++++ b/src/globals.c +@@ -717,9 +717,13 @@ S_tokenNameIni s_tokenNameIniTab2[] = { + {"__inline__", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__volatile", VOLATILE ,LAN_C | LAN_YACC | LAN_CCC}, + {"__volatile__", VOLATILE ,LAN_C | LAN_YACC | LAN_CCC}, +- {"__asm", ASM_KEYWORD ,LAN_C | LAN_CCC}, +- {"__asm__", ASM_KEYWORD ,LAN_C | LAN_CCC}, +- {"__label__", LABEL ,LAN_C | LAN_CCC}, ++ {"__asm", ASM_KEYWORD ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__asm__", ASM_KEYWORD ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__label__", LABEL ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__threadd", _THREADLOCAL ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__restrict", RESTRICT ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__restrict__", RESTRICT ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__extension__", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__near", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__far", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__pascal", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, +-- +2.18.0 + diff --git a/0021-Add-GCC-built-in-functions.patch b/0021-Add-GCC-built-in-functions.patch new file mode 100644 index 000000000000..9afd5eabd27c --- /dev/null +++ b/0021-Add-GCC-built-in-functions.patch @@ -0,0 +1,181 @@ +From d83bcb77f0610b0c8f560c8275f9638e5b3d805d Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Fri, 16 Jun 2017 22:10:08 +0300 +Subject: [PATCH 21/33] Add GCC built-in functions + +--- + src/options.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 151 insertions(+) + +diff --git a/src/options.c b/src/options.c +index 555e59e..2c40574 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -44,6 +44,81 @@ static char *s_standardCOptions[] = { + "-Dtypeof(xxx) int", + "-D__typeof__(xxx) int", + "-D__gnuc_va_list void", ++ "-D__builtin_va_list void", ++ "-D__builtin_va_start(v, l) ", ++ "-D__builtin_va_end(v) ", ++ "-D__builtin_va_arg(v, l) 0", ++ "-D__builtin_va_copy(d, s) ", ++ "-D__builtin_offsetof(a, b) 8", ++ "-D__builtin_types_compatible_p(a, b) 0" ++ "-D__builtin_alloca(size) 0", ++ "-D__builtin_alloca_with_align(size, alignment) 0", ++ "-D__builtin_types_compatible_p(type1, type2) 0", ++ "-D__builtin_call_with_static_chain(call_exp, pointer_exp) 0", ++ "-D__builtin_choose_expr(const_exp, exp1, exp2) exp1", ++ "-D__builtin_complex(real, imag) 0", ++ "-D__builtin_constant_p(exp) 0", ++ "-D__builtin_expect(exp, c) 0", ++ "-D__builtin_trap() ", ++ "-D__builtin_unreachable() ", ++ "-D__builtin_assume_aligned(const void *exp, size_t align, ...) 0", ++ "-D__builtin_LINE() 0", ++ "-D__builtin_FUNCTION() \"__FUNCTION__\"", ++ "-D__builtin_FILE() \"__FILE__\"", ++ "-D__builtin___clear_cache(begin, end) ", ++ "-D__builtin_prefetch(addr, ...) ", ++ "-D__builtin_huge_val() 0", ++ "-D__builtin_huge_valf() 0", ++ "-D__builtin_huge_vall() 0", ++ "-D__builtin_huge_valfn() 0", ++ "-D__builtin_huge_valfnx() 0", ++ "-D__builtin_fpclassify(a, b, c, d, e, ...) 0", ++ "-D__builtin_inf() 0", ++ "-D__builtin_infd32() 0", ++ "-D__builtin_infd64() 0", ++ "-D__builtin_infd128() 0", ++ "-D__builtin_inff() 0", ++ "-D__builtin_infl() 0", ++ "-D__builtin_inffn() 0", ++ "-D__builtin_inffnx() 0", ++ "-D__builtin_isinf_sign(...) 0", ++ "-D__builtin_nan(str) 0", ++ "-D__builtin_nand32(str) 0", ++ "-D__builtin_nand64(str) 0", ++ "-D__builtin_nand128(str) 0", ++ "-D__builtin_nanf(str) 0", ++ "-D__builtin_nanl(str) 0", ++ "-D__builtin_nanfn(str) 0", ++ "-D__builtin_nanfnx(str) 0", ++ "-D__builtin_nans(str) 0", ++ "-D__builtin_nansf(str) 0", ++ "-D__builtin_nansl(str) 0", ++ "-D__builtin_nansfn(str) 0", ++ "-D__builtin_nansfnx(const char *str) 0", ++ "-D__builtin_ffs(x) 0", ++ "-D__builtin_clz(x) 0", ++ "-D__builtin_ctz(x) 0", ++ "-D__builtin_clrsb(x) 0", ++ "-D__builtin_popcount(x) 0", ++ "-D__builtin_parity(x) 0", ++ "-D__builtin_ffsl(x) 0", ++ "-D__builtin_clzl(x) 0", ++ "-D__builtin_ctzl(x) 0", ++ "-D__builtin_clrsbl(x) 0", ++ "-D__builtin_popcountl(x) 0", ++ "-D__builtin_parityl() 0", ++ "-D__builtin_ffsll(x) 0", ++ "-D__builtin_clzll(x) 0", ++ "-D__builtin_ctzll(x) 0", ++ "-D__builtin_clrsbll(x) 0", ++ "-D__builtin_popcountll(x) 0", ++ "-D__builtin_parityll(0) 0", ++ "-D__builtin_powi(x, y) 0", ++ "-D__builtin_powif(x, y) 0", ++ "-D__builtin_powil(x, y) 0", ++ "-D__builtin_bswap16(x) 0", ++ "-D__builtin_bswap32(x) 0", ++ "-D__builtin_bswap64(x) 0", + #endif /*SBD*/ + + }; +@@ -66,6 +141,82 @@ static char *s_standardCccOptions[] = { + "-D__alignof__(xxx) 8", + "-Dtypeof(xxx) int", + "-D__typeof__(xxx) int", ++ "-D__gnuc_va_list void", ++ "-D__builtin_va_list void", ++ "-D__builtin_va_start(v, l) ", ++ "-D__builtin_va_end(v) ", ++ "-D__builtin_va_arg(v, l) 0", ++ "-D__builtin_va_copy(d, s) ", ++ "-D__builtin_offsetof(a, b) 8", ++ "-D__builtin_types_compatible_p(a, b) 0" ++ "-D__builtin_alloca(size) 0", ++ "-D__builtin_alloca_with_align(size, alignment) 0", ++ "-D__builtin_types_compatible_p(type1, type2) 0", ++ "-D__builtin_call_with_static_chain(call_exp, pointer_exp) 0", ++ "-D__builtin_choose_expr(const_exp, exp1, exp2) exp1", ++ "-D__builtin_complex(real, imag) 0", ++ "-D__builtin_constant_p(exp) 0", ++ "-D__builtin_expect(exp, c) 0", ++ "-D__builtin_trap() ", ++ "-D__builtin_unreachable() ", ++ "-D__builtin_assume_aligned(const void *exp, size_t align, ...) 0", ++ "-D__builtin_LINE() 0", ++ "-D__builtin_FUNCTION() \"__FUNCTION__\"", ++ "-D__builtin_FILE() \"__FILE__\"", ++ "-D__builtin___clear_cache(begin, end) ", ++ "-D__builtin_prefetch(addr, ...) ", ++ "-D__builtin_huge_val() 0", ++ "-D__builtin_huge_valf() 0", ++ "-D__builtin_huge_vall() 0", ++ "-D__builtin_huge_valfn() 0", ++ "-D__builtin_huge_valfnx() 0", ++ "-D__builtin_fpclassify(a, b, c, d, e, ...) 0", ++ "-D__builtin_inf() 0", ++ "-D__builtin_infd32() 0", ++ "-D__builtin_infd64() 0", ++ "-D__builtin_infd128() 0", ++ "-D__builtin_inff() 0", ++ "-D__builtin_infl() 0", ++ "-D__builtin_inffn() 0", ++ "-D__builtin_inffnx() 0", ++ "-D__builtin_isinf_sign(...) 0", ++ "-D__builtin_nan(str) 0", ++ "-D__builtin_nand32(str) 0", ++ "-D__builtin_nand64(str) 0", ++ "-D__builtin_nand128(str) 0", ++ "-D__builtin_nanf(str) 0", ++ "-D__builtin_nanl(str) 0", ++ "-D__builtin_nanfn(str) 0", ++ "-D__builtin_nanfnx(str) 0", ++ "-D__builtin_nans(str) 0", ++ "-D__builtin_nansf(str) 0", ++ "-D__builtin_nansl(str) 0", ++ "-D__builtin_nansfn(str) 0", ++ "-D__builtin_nansfnx(const char *str) 0", ++ "-D__builtin_ffs(x) 0", ++ "-D__builtin_clz(x) 0", ++ "-D__builtin_ctz(x) 0", ++ "-D__builtin_clrsb(x) 0", ++ "-D__builtin_popcount(x) 0", ++ "-D__builtin_parity(x) 0", ++ "-D__builtin_ffsl(x) 0", ++ "-D__builtin_clzl(x) 0", ++ "-D__builtin_ctzl(x) 0", ++ "-D__builtin_clrsbl(x) 0", ++ "-D__builtin_popcountl(x) 0", ++ "-D__builtin_parityl() 0", ++ "-D__builtin_ffsll(x) 0", ++ "-D__builtin_clzll(x) 0", ++ "-D__builtin_ctzll(x) 0", ++ "-D__builtin_clrsbll(x) 0", ++ "-D__builtin_popcountll(x) 0", ++ "-D__builtin_parityll(0) 0", ++ "-D__builtin_powi(x, y) 0", ++ "-D__builtin_powif(x, y) 0", ++ "-D__builtin_powil(x, y) 0", ++ "-D__builtin_bswap16(x) 0", ++ "-D__builtin_bswap32(x) 0", ++ "-D__builtin_bswap64(x) 0", + #endif /*SBD*/ + + }; +-- +2.18.0 + diff --git a/0022-Fix-macro-expansion-for-constant-parameters.patch b/0022-Fix-macro-expansion-for-constant-parameters.patch new file mode 100644 index 000000000000..9c960e157325 --- /dev/null +++ b/0022-Fix-macro-expansion-for-constant-parameters.patch @@ -0,0 +1,49 @@ +From ec2300f18c2296b29a7c559ca4ab4dc20d7c06b2 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Thu, 15 Jun 2017 03:46:56 +0300 +Subject: [PATCH 22/33] Fix ## macro expansion for constant parameters + +--- + src/yylex.c | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/src/yylex.c b/src/yylex.c +index 2431e75..0af4dcc 100644 +--- a/src/yylex.c ++++ b/src/yylex.c +@@ -1297,7 +1297,7 @@ static void cxAddCollateReference( char *sym, char *cs, S_position *pos ) { + static void collate(char **albcc, char **abcc, char *buf, int *absize, + char **ancc, S_lexInput *actArgs) { + char *lbcc,*bcc,*cc,*ccfin,*cc0,*ncc,*cc1,*occ; +- int line, val, lex, nlex, len1, bsize, nlt,len; ++ int line, val, lex, nlex, len1, bsize, nlt, len, cch; + S_position pos,respos; + unsigned hash; + ncc = *ancc; +@@ -1367,6 +1367,23 @@ static void collate(char **albcc, char **abcc, char *buf, int *absize, + PutLexPosition(respos.file,respos.line,respos.coll,bcc); + } + } ++ if (lbcc!=NULL && cc < ccfin && NextLexToken(lbcc) == CONSTANT) { ++ nlex = NextLexToken(cc); ++ if (IS_IDENTIFIER_LEXEM(nlex) || nlex == CONSTANT ++ || nlex == LONG_CONSTANT || nlex == FLOAT_CONSTANT ++ || nlex == DOUBLE_CONSTANT ) { ++ GetLexToken(lex, cc); ++ occ = cc; ++ PassLex(cc, lex, line, val, hash, respos, len, 0); ++ if (IS_IDENTIFIER_LEXEM(lex)) { ++ GetLexChar(cch, occ); ++ for(; cch=='l'||cch=='L'||cch=='u'||cch=='U'; ) { ++ if (cch=='l' || cch=='L') PutLexToken(LONG_CONSTANT, lbcc); ++ GetLexChar(cch, occ); ++ } ++ } ++ } ++ } + TestPPBufOverflow(bcc,buf,bsize); + while (cc<ccfin) { + cc0 = cc; +-- +2.18.0 + diff --git a/0023-Fix-__VA_ARGS__-expansion-in-macro-if-variable-argum.patch b/0023-Fix-__VA_ARGS__-expansion-in-macro-if-variable-argum.patch new file mode 100644 index 000000000000..0e1cc90fb1c5 --- /dev/null +++ b/0023-Fix-__VA_ARGS__-expansion-in-macro-if-variable-argum.patch @@ -0,0 +1,28 @@ +From 3274f5bae444c2bc62011598a85edeecaad979b9 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Thu, 22 Jun 2017 20:38:52 +0300 +Subject: [PATCH 23/33] Fix ##__VA_ARGS__ expansion in macro if variable + arguments are omitted + +--- + src/yylex.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/yylex.c b/src/yylex.c +index 0af4dcc..5cb5ff5 100644 +--- a/src/yylex.c ++++ b/src/yylex.c +@@ -1327,6 +1327,10 @@ static void collate(char **albcc, char **abcc, char *buf, int *absize, + GetLexToken(lex, ncc); + PassLex(ncc, lex, line, val, hash, pos, len, 0); + cc = actArgs[val].a; ccfin = actArgs[val].fin; ++ if (! (cc < ccfin) && NextLexToken(lbcc) == ',') { ++ bcc = lbcc; ++ lbcc = NULL; ++ } + } else { + cc = ncc; + GetLexToken(lex, ncc); +-- +2.18.0 + diff --git a/0024-Allow-to-process-.y-files-and-refine-C-grammar-in-ya.patch b/0024-Allow-to-process-.y-files-and-refine-C-grammar-in-ya.patch new file mode 100644 index 000000000000..dada4797ebb9 --- /dev/null +++ b/0024-Allow-to-process-.y-files-and-refine-C-grammar-in-ya.patch @@ -0,0 +1,1007 @@ +From d4d10f7cd73657b161a2c5344c6295e9e9e9d634 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Wed, 15 Mar 2017 13:45:37 +0300 +Subject: [PATCH 24/33] Allow to process .y files and refine C grammar in + yaccgram.y + +--- + src/Makefile | 2 +- + src/cgram.y | 2 - + src/yaccgram.y | 568 ++++++++++++++++++++++++++++++++++++------------- + 3 files changed, 426 insertions(+), 146 deletions(-) + +diff --git a/src/Makefile b/src/Makefile +index f0b6977..9d6ebb0 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -1,7 +1,7 @@ + ######################################################################### + CC= gcc + COMCFLAGS= $(INCLUDES) -DDEBUG $(ZLIB_OPT) \ +- -DBIN_RELEASE -DPRESERVE_C_ARGS -D__mygnulinux__ ++ -DBIN_RELEASE -DPRESERVE_C_ARGS -D__mygnulinux__ -DYACC_ALLOWED + CFLAGS= -c -O $(COMCFLAGS) + EDGCFLAGS= -O + LDFLAGS= +diff --git a/src/cgram.y b/src/cgram.y +index 58020dd..a0559f7 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -59,8 +59,6 @@ + + #define CrTypeModifier(xxx,ttt) {\ + xxx = crSimpleTypeMofifier(ttt);\ +- xxx = StackMemAlloc(S_typeModifiers);\ +- FILLF_typeModifiers(xxx, ttt,f,( NULL,NULL) ,NULL,NULL);\ + } + + #define AddComposedType(ddd, ttt) appendComposedType(&ddd->u.type, ttt) +diff --git a/src/yaccgram.y b/src/yaccgram.y +index 0bca507..8773040 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -33,19 +33,6 @@ + #define yyerror styyerror + #define yyErrorRecovery styyErrorRecovery + +- +-#define CrTypeModifier(xxx,ttt) {\ +- xxx = StackMemAlloc(S_typeModifiers);\ +- FILLF_typeModifiers(xxx, ttt,f,( NULL,NULL) ,NULL,NULL);\ +-} +- +-#define PrependModifier(xxx,ttt) {\ +- S_typeModifiers *p;\ +- p = StackMemAlloc(S_typeModifiers);\ +- FILLF_typeModifiers(p, ttt, NULL,NULL,NULL,xxx);\ +- xxx = p;\ +-} +- + #define SetStrCompl1(xxx) {\ + assert(s_opt.taskRegime);\ + if (s_opt.taskRegime == RegimeEditServer) {\ +@@ -61,6 +48,10 @@ + }\ + } + ++#define CrTypeModifier(xxx,ttt) {\ ++ xxx = crSimpleTypeMofifier(ttt);\ ++} ++ + #define AddComposedType(ddd, ttt) appendComposedType(&ddd->u.type, ttt) + + #define AddHtmlTrivialReference(pos) {\ +@@ -263,12 +254,15 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + S_bb_nestedConstrTokenType bbnestedConstrTokenType; + } + ++ + %type <bbidIdent> IDENTIFIER identifier struct_identifier enum_identifier + %type <bbidIdent> str_rec_identifier STRUCT UNION struct_or_union + %type <bbidIdent> user_defined_type TYPE_NAME lexem + %type <bbinteger> pointer CONSTANT rule_body + %type <bbidIdent> designator designator_list + %type <bbidlist> designation_opt initializer initializer_list initializer_list_opt eq_initializer_opt ++%type <bbinteger> assignment_operator ++%type <bbinteger> pointer CONSTANT _ncounter_ _nlabel_ _ngoto_ _nfork_ + %type <bbunsign> storage_class_specifier type_specifier1 + %type <bbunsign> type_modality_specifier Sv_tmp + %type <bbsymbol> init_declarator declarator declarator2 struct_declarator +@@ -285,7 +279,7 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + %type <bbsymbol> fun_arg_init_declarations fun_arg_declaration + %type <bbsymbolPositionLstPair> parameter_list parameter_type_list + %type <bbsymbolPositionLstPair> parameter_identifier_list identifier_list +-%type <bbpositionLst> argument_expr_list ++%type <bbpositionLst> argument_expr_list argument_expr_list_opt + + %type <bbtypeModif> type_specifier2 + %type <bbtypeModif> struct_or_union_specifier struct_or_union_define_specifier +@@ -296,7 +290,7 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + %type <bbexprType> multiplicative_expr additive_expr shift_expr + %type <bbexprType> relational_expr equality_expr and_expr exclusive_or_expr + %type <bbexprType> inclusive_or_expr logical_and_expr logical_or_expr +-%type <bbexprType> conditional_expr assignment_expr expr ++%type <bbexprType> conditional_expr assignment_expr expr maybe_expr + + %type <bbposition> STRING_LITERAL '(' ',' ')' + +@@ -519,6 +513,8 @@ primary_expr + assert(s_opt.taskRegime); + if (CX_REGIME()) { + $$.d.r = addCxReference(p, &$1.d->p, UsageUsed,s_noneFileIndex, s_noneFileIndex); ++ } else { ++ $$.d.r = NULL; + } + } else { + /* implicit function declaration */ +@@ -529,11 +525,15 @@ primary_expr + $$.d.t = StackMemAlloc(S_typeModifiers); + FILLF_typeModifiers($$.d.t, TypeFunction,f,( NULL,NULL) ,NULL,p); + d = StackMemAlloc(S_symbol); +- FILL_symbolBits(&d->b,0,0,0,0,0,TypeDefault, StorageExtern,0); ++ FILL_symbolBits(&d->b,0,0,0,0,0,TypeDefault, StorageExtern, 0); + FILL_symbol(d,$1.d->name,$1.d->name,$1.d->p,d->b,type,$$.d.t,NULL); + d->u.type = $$.d.t; + dd = addNewSymbolDef(d, StorageExtern, s_symTab, UsageUsed); +- $$.d.r = NULL; ++ if (CX_REGIME()) { ++ $$.d.r = addCxReference(dd, &$1.d->p, UsageUsed, s_noneFileIndex, s_noneFileIndex); ++ } else { ++ $$.d.r = NULL; ++ } + } + } + | CHAR_LITERAL { CrTypeModifier($$.d.t, TypeInt); $$.d.r = NULL;} +@@ -541,7 +541,7 @@ primary_expr + | LONG_CONSTANT { CrTypeModifier($$.d.t, TypeLong); $$.d.r = NULL;} + | FLOAT_CONSTANT { CrTypeModifier($$.d.t, TypeFloat); $$.d.r = NULL;} + | DOUBLE_CONSTANT { CrTypeModifier($$.d.t, TypeDouble); $$.d.r = NULL;} +- | STRING_LITERAL { ++ | string_literales { + S_typeModifiers *p; + CrTypeModifier(p, TypeChar); + $$.d.t = StackMemAlloc(S_typeModifiers); +@@ -558,6 +558,11 @@ primary_expr + | COMPL_OTHER_NAME { assert(0); /* token never used */ } + ; + ++string_literales: ++ STRING_LITERAL ++ | STRING_LITERAL string_literales ++ ; ++ + postfix_expr + : primary_expr /* { $$.d = $1.d; } */ + | postfix_expr '[' expr ']' { +@@ -567,6 +572,7 @@ postfix_expr + $$.d.r = NULL; + assert($$.d.t); + } ++/* + | postfix_expr '(' ')' { + if ($1.d.t->m==TypeFunction) { + $$.d.t=$1.d.t->next; +@@ -577,10 +583,21 @@ postfix_expr + $$.d.r = NULL; + assert($$.d.t); + } +- | postfix_expr '(' argument_expr_list ')' { ++*/ ++ | postfix_expr ++ { ++ $<typeModif>$ = s_upLevelFunctionCompletionType; ++ s_upLevelFunctionCompletionType = $1.d.t; ++ } ++ '(' argument_expr_list_opt ')' { ++ s_upLevelFunctionCompletionType = $<typeModif>2; + if ($1.d.t->m==TypeFunction) { + $$.d.t=$1.d.t->next; +- handleInvocationParamPositions($1.d.r, &$2.d, $3.d, &$4.d, 1); ++ if ($4.d==NULL) { ++ handleInvocationParamPositions($1.d.r, &$3.d, NULL, &$5.d, 0); ++ } else { ++ handleInvocationParamPositions($1.d.r, &$3.d, $4.d->next, &$5.d, 1); ++ } + } else { + $$.d.t = &s_errorModifier; + } +@@ -605,8 +622,14 @@ postfix_expr + } else $$.d.t = &s_errorModifier; + assert($$.d.t); + } +- | postfix_expr INC_OP { $$.d.t = $1.d.t; $$.d.r = NULL;} +- | postfix_expr DEC_OP { $$.d.t = $1.d.t; $$.d.r = NULL;} ++ | postfix_expr INC_OP { ++ $$.d.t = $1.d.t; ++ RESET_REFERENCE_USAGE($1.d.r, UsageAddrUsed); ++ } ++ | postfix_expr DEC_OP { ++ $$.d.t = $1.d.t; ++ RESET_REFERENCE_USAGE($1.d.r, UsageAddrUsed); ++ } + ; + + str_rec_identifier +@@ -614,20 +637,37 @@ str_rec_identifier + | COMPL_STRUCT_REC_NAME { assert(0); /* token never used */ } + ; + ++argument_expr_list_opt: { ++ $$.d = NULL; ++ } ++ | argument_expr_list { ++ XX_ALLOC($$.d, S_positionLst); ++ FILL_positionLst($$.d, s_noPos, $1.d); ++ } ++ ; ++ + argument_expr_list +- : assignment_expr { +- $$.d = NULL; ++ : assignment_expr { ++ $$.d = NULL; + } + | argument_expr_list ',' assignment_expr { + $$.d = $1.d; + appendPositionToList(&$$.d, &$2.d); + } ++ | COMPL_UP_FUN_PROFILE {/* never used */} ++ | argument_expr_list ',' COMPL_UP_FUN_PROFILE {/* never used */} + ; + + unary_expr + : postfix_expr /* { $$.d = $1.d; } */ +- | INC_OP unary_expr { $$.d.t = $2.d.t; $$.d.r = NULL;} +- | DEC_OP unary_expr { $$.d.t = $2.d.t; $$.d.r = NULL;} ++ | INC_OP unary_expr { ++ $$.d.t = $2.d.t; ++ RESET_REFERENCE_USAGE($2.d.r, UsageAddrUsed); ++ } ++ | DEC_OP unary_expr { ++ $$.d.t = $2.d.t; ++ RESET_REFERENCE_USAGE($2.d.r, UsageAddrUsed); ++ } + | unary_operator cast_expr { $$.d.t = $2.d.t; $$.d.r = NULL;} + | '&' cast_expr { + $$.d.t = StackMemAlloc(S_typeModifiers); +@@ -649,6 +689,10 @@ unary_expr + CrTypeModifier($$.d.t, TypeInt); + $$.d.r = NULL; + } ++ /* yet another GCC ext. */ ++ | AND_OP identifier { ++ labelReference($2.d, UsageLvalUsed); ++ } + ; + + unary_operator +@@ -796,29 +840,48 @@ conditional_expr + $$.d.t = $3.d.t; + $$.d.r = NULL; + } ++/* other GCC improvement, grrr */ ++ | logical_or_expr '?' ':' conditional_expr { ++ $$.d.t = $4.d.t; ++ $$.d.r = NULL; ++ } + ; + + assignment_expr + : conditional_expr /* { $$.d = $1.d; } */ +- | unary_expr assignment_operator assignment_expr { +- RESET_REFERENCE_USAGE($1.d.r, UsageLvalUsed); +- $$.d.t = $1.d.t; +- $$.d.r = NULL; ++ | unary_expr assignment_operator assignment_expr { ++ if ($1.d.r != NULL && s_opt.cxrefs == OLO_EXTRACT) { ++ S_reference *rr; ++ rr = duplicateReference($1.d.r); ++ $1.d.r->usg = s_noUsage; ++ if ($2.d == '=') { ++ RESET_REFERENCE_USAGE(rr, UsageLvalUsed); ++ } else { ++ RESET_REFERENCE_USAGE(rr, UsageAddrUsed); ++ } ++ } else { ++ if ($2.d == '=') { ++ RESET_REFERENCE_USAGE($1.d.r, UsageLvalUsed); ++ } else { ++ RESET_REFERENCE_USAGE($1.d.r, UsageAddrUsed); ++ } ++ } ++ $$.d = $1.d; /* $$.d.r will be used for FOR completions ! */ + } + ; + + assignment_operator +- : '=' +- | MUL_ASSIGN +- | DIV_ASSIGN +- | MOD_ASSIGN +- | ADD_ASSIGN +- | SUB_ASSIGN +- | LEFT_ASSIGN +- | RIGHT_ASSIGN +- | AND_ASSIGN +- | XOR_ASSIGN +- | OR_ASSIGN ++ : '=' {$$.d = '=';} ++ | MUL_ASSIGN {$$.d = MUL_ASSIGN;} ++ | DIV_ASSIGN {$$.d = DIV_ASSIGN;} ++ | MOD_ASSIGN {$$.d = MOD_ASSIGN;} ++ | ADD_ASSIGN {$$.d = ADD_ASSIGN;} ++ | SUB_ASSIGN {$$.d = SUB_ASSIGN;} ++ | LEFT_ASSIGN {$$.d = LEFT_ASSIGN;} ++ | RIGHT_ASSIGN {$$.d = RIGHT_ASSIGN;} ++ | AND_ASSIGN {$$.d = AND_ASSIGN;} ++ | XOR_ASSIGN {$$.d = XOR_ASSIGN;} ++ | OR_ASSIGN {$$.d = OR_ASSIGN;} + ; + + expr +@@ -846,34 +909,36 @@ declaration + ; + + init_declarations +- : declaration_specifiers init_declarator { ++ : declaration_specifiers init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $2.d, NULL, StorageAuto,s_symTab); ++ addNewDeclaration($1.d, $2.d, $3.d, StorageAuto, s_symTab); + } +- | init_declarations ',' init_declarator { ++ | init_declarations ',' init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $3.d, NULL, StorageAuto,s_symTab); ++ addNewDeclaration($1.d, $3.d, $4.d, StorageAuto, s_symTab); + } +- | error { +- /*$$.d = &s_errorSymbol;*/ +- XX_ALLOC($$.d, S_symbol); +- *$$.d = s_errorSymbol; ++ | error { ++ /* $$.d = &s_errorSymbol; */ ++ $$.d = typeSpecifier2(&s_errorModifier); + } + ; + + declaration_specifiers +- : declaration_modality_specifiers /* { $$.d = $1.d; } */ +- | declaration_specifiers0 /* { $$.d = $1.d; } */ ++ : declaration_modality_specifiers ++ | declaration_specifiers0 + ; + + user_defined_type + : TYPE_NAME { ++ int usage; + $$.d = $1.d; + assert(s_opt.taskRegime); + if (CX_REGIME()) { + assert($1.d); + assert($1.d->sd); +- addCxReference($1.d->sd, &$1.d->p, UsageUsed,s_noneFileIndex, s_noneFileIndex); ++ if (WORK_NEST_LEVEL1()) usage = USAGE_TOP_LEVEL_USED; ++ else usage = UsageUsed; ++ addCxReference($1.d->sd,&$1.d->p,usage,s_noneFileIndex,s_noneFileIndex); + } + } + ; +@@ -882,7 +947,6 @@ declaration_specifiers0 + : user_defined_type { + assert($1.d); + assert($1.d->sd); +- assert($1.d->sd); + $$.d = typeSpecifier2($1.d->sd->u.type); + } + | type_specifier1 { +@@ -894,7 +958,6 @@ declaration_specifiers0 + | declaration_modality_specifiers user_defined_type { + assert($2.d); + assert($2.d->sd); +- assert($2.d->sd); + $$.d = $1.d; + declTypeSpecifier2($1.d,$2.d->sd->u.type); + } +@@ -935,13 +998,8 @@ declaration_specifiers0 + + declaration_modality_specifiers + : storage_class_specifier { +- S_typeModifiers *p; +- p = StackMemAlloc(S_typeModifiers); +- FILLF_typeModifiers(p,TypeDefault,f,(NULL,NULL) ,NULL,NULL); +- $$.d = StackMemAlloc(S_symbol); +- FILL_symbolBits(&$$.d->b,0,0,0,0,0,TypeDefault,$1.d,0); +- FILL_symbol($$.d,NULL,NULL,s_noPos,$$.d->b,type,p,NULL); +- $$.d->u.type = p; ++ $$.d = typeSpecifier1(TypeDefault); ++ $$.d->b.storage = $1.d; + } + | declaration_modality_specifiers storage_class_specifier { + $$.d = $1.d; +@@ -961,11 +1019,51 @@ declaration_modality_specifiers + } + ; + ++/*& // an experiment ++declaration_specifier0: ++ storage_class_specifier ++ | type_modality_specifier ++ ; ++ ++declaration_specifiers0: ++ declaration_specifier0 ++ | declaration_specifiers0 declaration_specifier0 ++ ; ++ ++declaration_specifiers: ++ user_defined_type ++ | declaration_specifiers0 user_defined_type ++ | declaration_specifiers0 type_specifier1 ++ | declaration_specifiers0 type_specifier2 ++ | declaration_specifiers declaration_specifier0 ++ | declaration_specifiers type_specifier1 ++ | declaration_specifiers type_specifier2 ++ ; ++&*/ ++ ++/* a gcc extensions ? */ ++asm_opt: ++ | ASM_KEYWORD '(' string_literales ')' ++ ; ++ ++eq_initializer_opt: { ++ $$.d = NULL; ++ } ++ | '=' initializer { ++ $$.d = $2.d; ++ } ++ ; ++ + init_declarator +- : declarator /* { $$.d = $1.d; } */ +- | declarator '=' initializer /* { $$.d = $1.d; } */ ++ : declarator asm_opt /* eq_initializer_opt { $$.d = $1.d; } */ + ; + ++/* the original ++ : declarator ++ | declarator '=' initializer ++ ; ++*/ ++ + storage_class_specifier + : TYPEDEF { $$.d = StorageTypedef; } + | EXTERN { $$.d = StorageExtern; } +@@ -983,6 +1081,10 @@ type_modality_specifier + | ANONYME_MOD { $$.d = TypeDefault; } + ; + ++type_modality_specifier_opt: ++ | type_modality_specifier ++ ; ++ + type_specifier1 + : CHAR { $$.d = TypeChar; } + | SHORT { $$.d = TmodShort; } +@@ -1008,13 +1110,19 @@ function_specifier + + struct_or_union_specifier + : struct_or_union struct_identifier { +- $$.d = simpleStrUnionSpecifier($1.d, $2.d, UsageUsed); ++ int usage; ++ if (WORK_NEST_LEVEL1()) usage = USAGE_TOP_LEVEL_USED; ++ else usage = UsageUsed; ++ $$.d = simpleStrUnionSpecifier($1.d, $2.d, usage); + } + | struct_or_union_define_specifier '{' struct_declaration_list '}'{ + assert($1.d && $1.d->u.t); + $$.d = $1.d; + specializeStrUnionDef($$.d->u.t, $3.d); + } ++ | struct_or_union_define_specifier '{' '}' { ++ $$.d = $1.d; ++ } + ; + + struct_or_union_define_specifier +@@ -1041,7 +1149,7 @@ struct_declaration_list + | struct_declaration_list struct_declaration { + if ($1.d == &s_errorSymbol || $1.d->b.symType==TypeError) { + $$.d = $2.d; +- } else if ($2.d == &s_errorSymbol || $1.d->b.symType==TypeError) { ++ } else if ($2.d == &s_errorSymbol || $1.d->b.symType==TypeError) { + $$.d = $1.d; + } else { + $$.d = $1.d; +@@ -1061,7 +1169,7 @@ struct_declaration + tmpWorkMemoryi = $1.d; + } + | error { +- /*$$.d = &s_errorSymbol;*/ ++ /* $$.d = &s_errorSymbol; */ + XX_ALLOC($$.d, S_symbol); + *$$.d = s_errorSymbol; + } +@@ -1079,23 +1187,22 @@ struct_declarator_list + } + ; + +-struct_declarator +- : declarator /* { $$.d = $1.d; } */ ++struct_declarator: { /* gcc extension allow empty field */ ++ $$.d = crEmptyField(); ++ } + | ':' constant_expr { +- S_typeModifiers *p; +- p = StackMemAlloc(S_typeModifiers); +- FILLF_typeModifiers(p,TypeAnonymeField,f,( NULL,NULL) ,NULL,NULL); +- $$.d = StackMemAlloc(S_symbol); +- FILL_symbolBits(&$$.d->b,0,0,0,0,0,TypeDefault,StorageDefault,0); +- FILL_symbol($$.d, NULL, NULL, s_noPos,$$.d->b,type,p,NULL); +- $$.d->u.type = p; ++ $$.d = crEmptyField(); + } ++ | declarator /* { $$.d = $1.d; } */ + | declarator ':' constant_expr /* { $$.d = $1.d; } */ + ; + + enum_specifier + : ENUM enum_identifier { +- $$.d = simpleEnumSpecifier($2.d, UsageUsed); ++ int usage; ++ if (WORK_NEST_LEVEL1()) usage = USAGE_TOP_LEVEL_USED; ++ else usage = UsageUsed; ++ $$.d = simpleEnumSpecifier($2.d, usage); + } + | enum_define_specifier '{' enumerator_list_comma '}' { + assert($1.d && $1.d->m == TypeEnum && $1.d->u.t); +@@ -1146,7 +1253,7 @@ enumerator + addNewSymbolDef($$.d,StorageConstant, s_symTab, UsageDefined); + } + | error { +- /*$$.d = &s_errorSymbol;*/ ++ /* $$.d = &s_errorSymbol; */ + XX_ALLOC($$.d, S_symbol); + *$$.d = s_errorSymbol; + } +@@ -1156,15 +1263,14 @@ enumerator + declarator + : declarator2 /* { $$.d = $1.d; } */ + | pointer declarator2 { +- S_typeModifiers *p; +- int i; + $$.d = $2.d; +- for (i=0; i<$1.d; i++) AddComposedType($$.d,TypePointer); ++ assert($$.d->b.npointers == 0); ++ $$.d->b.npointers = $1.d; + } + ; + + declarator2 +- : IDENTIFIER { ++ : identifier { + $$.d = StackMemAlloc(S_symbol); + FILL_symbolBits(&$$.d->b,0,0,0,0,0,TypeDefault,StorageDefault,0); + FILL_symbol($$.d,$1.d->name,$1.d->name,$1.d->p,$$.d->b,type,NULL,NULL); +@@ -1172,6 +1278,7 @@ declarator2 + } + | '(' declarator ')' { + $$.d = $2.d; ++ unpackPointers($$.d); + } + | declarator2 '[' ']' { + assert($1.d); +@@ -1189,6 +1296,7 @@ declarator2 + $$.d = $1.d; + p = AddComposedType($$.d, TypeFunction); + FILL_funTypeModif(&p->u.f , NULL, NULL); ++ handleDeclaratorParamPositions($1.d, &$2.d, NULL, &$3.d, 0); + } + | declarator2 '(' parameter_type_list ')' { + S_typeModifiers *p; +@@ -1370,6 +1478,7 @@ parameter_list + } + ; + ++ + parameter_declaration + : declaration_specifiers declarator { + completeDeclarator($1.d, $2.d); +@@ -1379,9 +1488,16 @@ parameter_declaration + $$.d = StackMemAlloc(S_symbol); + FILL_symbolBits(&$$.d->b,0,0,0,0,0,TypeDefault, StorageDefault,0); + FILL_symbol($$.d, NULL, NULL, s_noPos,$$.d->b,type,$1.d,NULL); ++ $$.d->u.type = $1.d; + } + | error { +- /*$$.d = &s_errorSymbol;*/ ++ /* ++ this was commented out, because of excess of tmpWorkMemory ++ but I am putting it in, because in many cases, this helps ++ to index a function with wrong typedefed parameters, like: ++ void toto(Mistype arg) {} ++ In case of problems rather increase the tmpWorkMemory !!! ++ */ + XX_ALLOC($$.d, S_symbol); + *$$.d = s_errorSymbol; + } +@@ -1449,9 +1565,10 @@ abstract_declarator2 + S_typeModifiers *p; + $$.d = $1.d; + p = appendComposedType(&($$.d), TypeFunction); +- // why there was the following ????? +- // FILL_funTypeModif(&p->u.f , NULL, NULL); +- FILL_funTypeModif(&p->u.f , $3.d.s, NULL); ++ // I think there should be the following, but in abstract ++ // declarator it does not matter ++ //& FILL_funTypeModif(&p->u.f , $3.d.s, NULL); ++ FILL_funTypeModif(&p->u.f , NULL, NULL); + } + ; + +@@ -1544,14 +1661,29 @@ statement + | Sv_tmp jump_statement { + tmpWorkMemoryi = $1.d; + } +- | error ++ | Sv_tmp asm_statement { ++ tmpWorkMemoryi = $1.d; ++ } ++ | Sv_tmp error { ++ tmpWorkMemoryi = $1.d; ++ } ++ ; ++ ++label: ++ label_def_name ':' ++ | CASE constant_expr ':' { ++ GenSwitchCaseFork(0); ++ } ++ | CASE constant_expr ELIPSIS constant_expr ':' { ++ GenSwitchCaseFork(0); ++ } ++ | DEFAULT ':' { ++ GenSwitchCaseFork(0); ++ } + ; + + labeled_statement +- : label_def_name ':' statement +- | CASE constant_expr ':' statement +- | CASE constant_expr ELIPSIS constant_expr ':' statement +- | DEFAULT ':' statement ++ : label statement + ; + + label_def_name +@@ -1570,69 +1702,211 @@ label_name + + compound_statement + : '{' '}' +- | '{' Start_block statement_list Stop_block '}' +- | '{' Start_block declaration_list Stop_block '}' +- | '{' Start_block declaration_list statement_list Stop_block '}' ++ | '{' Start_block label_decls_opt statement_list Stop_block '}' ++/*& ++ | '{' Start_block label_decls_opt declaration_list Stop_block '}' ++ | '{' Start_block label_decls_opt declaration_list statement_list Stop_block '}' ++&*/ + ; + ++label_decls_opt: ++ | label_decls ++ ; ++ ++label_decls: ++ LABEL identifier { ++ labelReference($2.d,UsageDeclared); ++ } ++ | label_decls LABEL identifier { ++ labelReference($3.d,UsageDeclared); ++ } ++ ; ++ ++/*& + declaration_list + : declaration + | declaration_list declaration + ; ++&*/ ++ ++/* allowing declarations inside statements makes better error recovery. ++ If an error occurs in one of early declarations, this worked only ++ because of some strange recovering ++ */ + + statement_list + : statement + | statement_list statement +-/* + | declaration + | statement_list declaration +-*/ + ; + + maybe_expr +- : +- | expr ++ : { $$.d.t = NULL; $$.d.r = NULL; } ++ | expr { $$.d = $1.d; } + ; + + expression_statement + : maybe_expr ';' + ; + ++ ++_ncounter_: {EXTRACT_COUNTER_SEMACT($$.d);} ++ ; ++ ++_nlabel_: {EXTRACT_LABEL_SEMACT($$.d);} ++ ; ++ ++_ngoto_: {EXTRACT_GOTO_SEMACT($$.d);} ++ ; ++ ++_nfork_: {EXTRACT_FORK_SEMACT($$.d);} ++ ; ++ + selection_statement +- : IF '(' expr ')' statement +- | IF '(' expr ')' statement ELSE statement +- | SWITCH '(' expr ')' statement ++ : IF '(' expr ')' _nfork_ statement { ++ GenInternalLabelReference($5.d, UsageDefined); ++ } ++ | IF '(' expr ')' _nfork_ statement ELSE _ngoto_ { ++ GenInternalLabelReference($5.d, UsageDefined); ++ } statement { ++ GenInternalLabelReference($8.d, UsageDefined); ++ } ++ | SWITCH '(' expr ')' /*5*/ _ncounter_ {/*6*/ ++ AddContinueBreakLabelSymbol(1000*$5.d, SWITCH_LABEL_NAME, $<symbol>$); ++ } {/*7*/ ++ AddContinueBreakLabelSymbol($5.d, BREAK_LABEL_NAME, $<symbol>$); ++ GenInternalLabelReference($5.d, UsageFork); ++ } statement { ++ GenSwitchCaseFork(1); ++ ExtrDeleteContBreakSym($<symbol>7); ++ ExtrDeleteContBreakSym($<symbol>6); ++ GenInternalLabelReference($5.d, UsageDefined); ++ } ++ ; ++ ++for1maybe_expr: ++ maybe_expr {s_forCompletionType=$1.d;} + ; + + iteration_statement +- : WHILE '(' expr ')' statement +- | DO statement WHILE '(' expr ')' ';' +- | FOR '(' maybe_expr ';' maybe_expr ';' maybe_expr ')' statement ++ : WHILE _nlabel_ '(' expr ')' /*6*/ _nfork_ ++ {/*7*/ ++ AddContinueBreakLabelSymbol($2.d, CONTINUE_LABEL_NAME, $<symbol>$); ++ } {/*8*/ ++ AddContinueBreakLabelSymbol($6.d, BREAK_LABEL_NAME, $<symbol>$); ++ } statement { ++ ExtrDeleteContBreakSym($<symbol>8); ++ ExtrDeleteContBreakSym($<symbol>7); ++ GenInternalLabelReference($2.d, UsageUsed); ++ GenInternalLabelReference($6.d, UsageDefined); ++ } ++ ++ | DO _nlabel_ _ncounter_ _ncounter_ { /*5*/ ++ AddContinueBreakLabelSymbol($3.d, CONTINUE_LABEL_NAME, $<symbol>$); ++ } {/*6*/ ++ AddContinueBreakLabelSymbol($4.d, BREAK_LABEL_NAME, $<symbol>$); ++ } statement WHILE { ++ ExtrDeleteContBreakSym($<symbol>6); ++ ExtrDeleteContBreakSym($<symbol>5); ++ GenInternalLabelReference($3.d, UsageDefined); ++ } '(' expr ')' ';' { ++ GenInternalLabelReference($2.d, UsageFork); ++ GenInternalLabelReference($4.d, UsageDefined); ++ } ++ ++ | FOR '(' for1maybe_expr ';' ++ /*5*/ _nlabel_ maybe_expr ';' /*8*/_ngoto_ ++ /*9*/ _nlabel_ maybe_expr ')' /*12*/ _nfork_ ++ { ++ /*13*/ ++ GenInternalLabelReference($5.d, UsageUsed); ++ GenInternalLabelReference($8.d, UsageDefined); ++ AddContinueBreakLabelSymbol($9.d, CONTINUE_LABEL_NAME, $<symbol>$); ++ } ++ {/*14*/ ++ AddContinueBreakLabelSymbol($12.d, BREAK_LABEL_NAME, $<symbol>$); ++ } ++ statement ++ { ++ ExtrDeleteContBreakSym($<symbol>14); ++ ExtrDeleteContBreakSym($<symbol>13); ++ GenInternalLabelReference($9.d, UsageUsed); ++ GenInternalLabelReference($12.d, UsageDefined); ++ } ++ | FOR '(' for1maybe_expr ';' COMPL_FOR_SPECIAL1 ++ | FOR '(' for1maybe_expr ';' _nlabel_ maybe_expr ';' COMPL_FOR_SPECIAL2 + ; + + jump_statement + : GOTO label_name ';' +- | CONTINUE ';' +- | BREAK ';' +- | RETURN ';' +- | RETURN expr ';' ++ | CONTINUE ';' { ++ GenContBreakReference(CONTINUE_LABEL_NAME); ++ } ++ | BREAK ';' { ++ GenContBreakReference(BREAK_LABEL_NAME); ++ } ++ | RETURN ';' { ++ GenInternalLabelReference(-1, UsageUsed); ++ } ++ | RETURN expr ';' { ++ GenInternalLabelReference(-1, UsageUsed); ++ } ++ ; ++ ++_bef_: { ++ actionsBeforeAfterExternalDefinition(); ++ } ++ ; ++ ++/* ****************** following is some gcc asm support ************ */ ++/* it is not exactly as in gcc, but I hope it is suf. general */ ++ ++gcc_asm_symbolic_name_opt: ++ | '[' IDENTIFIER ']' + ; + ++gcc_asm_item_opt: ++ | gcc_asm_symbolic_name_opt IDENTIFIER ++ | gcc_asm_symbolic_name_opt IDENTIFIER '(' expr ')' ++ | gcc_asm_symbolic_name_opt string_literales ++ | gcc_asm_symbolic_name_opt string_literales '(' expr ')' ++ ; ++ ++gcc_asm_item_list: ++ gcc_asm_item_opt ++ | gcc_asm_item_list ',' gcc_asm_item_opt ++ ; ++ ++gcc_asm_oper: ++ ':' gcc_asm_item_list ++ | gcc_asm_oper ':' gcc_asm_item_list ++ ; ++ ++asm_statement: ++ ASM_KEYWORD type_modality_specifier_opt '(' expr ')' ';' ++ | ASM_KEYWORD type_modality_specifier_opt '(' expr gcc_asm_oper ')' ';' ++ ; ++ ++/* *********************************************************************** */ ++ + file +- : cached_external_definition_list +- | +- | cached_external_definition_list EOI_TOKEN +- Start_block statement_list Stop_block +- | EOI_TOKEN Start_block statement_list Stop_block ++ : _bef_ ++ | _bef_ cached_external_definition_list _bef_ + ; + + cached_external_definition_list +- : external_definition { +- /* poseCachePoint(1); no caching in yacc files */ ++ : external_definition { ++ if (inStacki == 0) { ++ poseCachePoint(1); ++ } + } +- | cached_external_definition_list external_definition { +- /* poseCachePoint(1); no caching in yacc files */ ++ | cached_external_definition_list _bef_ external_definition { ++ if (inStacki == 0) { ++ poseCachePoint(1); ++ } + } ++ | error + ; + + external_definition +@@ -1643,34 +1917,33 @@ external_definition + tmpWorkMemoryi = $1.d; + } + | Sv_tmp function_definition_head { +- S_symbol *p,*pa; ++ S_symbol *p,*pa,*pp; + int i; + assert($2.d); +- //&if ($2.d->b.storage == StorageDefault) $2.d->b.storage = StorageExtern; ++ // I think that due to the following line sometimes ++ // storage was not extern, see 'addNewSymbolDef' ++ //& if ($2.d->b.storage == StorageDefault) $2.d->b.storage = StorageExtern; ++ // TODO!!!, here you should check if there is previous declaration of ++ // the function, if yes and is declared static, make it static! + addNewSymbolDef($2.d, StorageExtern, s_symTab, UsageDefined); + tmpWorkMemoryi = $1.d; + stackMemoryBlockStart(); ++ s_count.localVar = 0; + assert($2.d->u.type && $2.d->u.type->m == TypeFunction); + s_cp.function = $2.d; ++ GenInternalLabelReference(-1, UsageDefined); + for(p=$2.d->u.type->u.f.args,i=1; p!=NULL; p=p->next,i++) { + if (p->b.symType == TypeElipsis) continue; + if (p->u.type == NULL) p->u.type = &s_defaultIntModifier; +- if (p->name != NULL) { +- XX_ALLOC(pa,S_symbol); +- *pa = *p; +- addNewSymbolDef(pa, StorageAuto, s_symTab, UsageDefined); +- } +- if (s_opt.cxrefs == OLO_GOTO_PARAM_NAME +- && i == s_opt.olcxGotoVal +- && POSITION_EQ($2.d->pos, s_cxRefPos)) { +- s_paramPosition = p->pos; +- } +- ++ addFunctionParameterToSymTable($2.d, p, i, s_symTab); + } + } compound_statement { + stackMemoryBlockFree(); + s_cp.function = NULL; + LICENSE_CHECK(); ++ if (s_opt.taskRegime == RegimeHtmlGenerate) { ++ htmlAddFunctionSeparatorReference(); ++ } + } + | Sv_tmp EXTERN STRING_LITERAL external_definition { + tmpWorkMemoryi = $1.d; +@@ -1678,27 +1951,36 @@ external_definition + | Sv_tmp EXTERN STRING_LITERAL '{' cached_external_definition_list '}' { + tmpWorkMemoryi = $1.d; + } +- | error compound_statement +- | error ';' ++ | Sv_tmp ASM_KEYWORD '(' expr ')' ';' { ++ tmpWorkMemoryi = $1.d; ++ } ++ | Sv_tmp error compound_statement { ++ tmpWorkMemoryi = $1.d; ++ } ++ | Sv_tmp error { ++ tmpWorkMemoryi = $1.d; ++ } ++ | Sv_tmp ';' { /* empty external definition */ ++ tmpWorkMemoryi = $1.d; ++ } + ; + + top_init_declarations +- : declaration_specifiers init_declarator { ++ : declaration_specifiers init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $2.d, NULL, StorageExtern,s_symTab); ++ addNewDeclaration($1.d, $2.d, $3.d, StorageExtern,s_symTab); + } +- | init_declarator { ++ | init_declarator eq_initializer_opt { + $$.d = & s_defaultIntDefinition; +- addNewDeclaration($$.d, $1.d, NULL, StorageExtern,s_symTab); ++ addNewDeclaration($$.d, $1.d, $2.d, StorageExtern,s_symTab); + } +- | top_init_declarations ',' init_declarator { ++ | top_init_declarations ',' init_declarator eq_initializer_opt { + $$.d = $1.d; +- addNewDeclaration($1.d, $3.d, NULL, StorageExtern,s_symTab); ++ addNewDeclaration($1.d, $3.d, $4.d, StorageExtern,s_symTab); + } +- | error { +- /*$$.d = &s_errorSymbol;*/ +- XX_ALLOC($$.d, S_symbol); +- *$$.d = s_errorSymbol; ++ | error { ++ /* $$.d = &s_errorSymbol; */ ++ $$.d = typeSpecifier2(&s_errorModifier); + } + ; + +@@ -1728,10 +2010,10 @@ fun_arg_declaration + ; + + fun_arg_init_declarations +- : init_declarator { ++ : init_declarator eq_initializer_opt { + $$.d = $1.d; + } +- | fun_arg_init_declarations ',' init_declarator { ++ | fun_arg_init_declarations ',' init_declarator eq_initializer_opt { + $$.d = $1.d; + LIST_APPEND(S_symbol, $$.d, $3.d); + } +-- +2.18.0 + diff --git a/0025-Parse-typeof-keyword.patch b/0025-Parse-typeof-keyword.patch new file mode 100644 index 000000000000..9b5c341c95ab --- /dev/null +++ b/0025-Parse-typeof-keyword.patch @@ -0,0 +1,319 @@ +From 40cea5e11ba6c7f36903b96c934eaa461064f790 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Fri, 23 Jun 2017 22:47:27 +0300 +Subject: [PATCH 25/33] Parse typeof keyword + +squash! Parse typeof keyword +--- + src/cgram.y | 38 +++++++++++++++++++++++++++----------- + src/globals.c | 4 +++- + src/javagram.y | 2 +- + src/options.c | 6 ++---- + src/yaccgram.y | 35 ++++++++++++++++++++++++++++++----- + 5 files changed, 63 insertions(+), 22 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index a0559f7..1ef4600 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -35,7 +35,6 @@ + #include "head.h" + #include "proto.h" /*SBD*/ + +- + #define YYDEBUG 0 + #define yyerror styyerror + #define yyErrorRecovery styyErrorRecovery +@@ -106,7 +105,7 @@ + + /* c-special */ + %token TYPEDEF EXTERN AUTO REGISTER SIGNED UNSIGNED STRUCT UNION ENUM +-%token SIZEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN ++%token SIZEOF TYPEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN + /* hmm */ + %token ANONYME_MOD + +@@ -190,7 +189,6 @@ + /* commons */ + %token IDENTIFIER CONSTANT LONG_CONSTANT + %token FLOAT_CONSTANT DOUBLE_CONSTANT +- + %token STRING_LITERAL + %token LINE_TOK + %token IDENT_TO_COMPLETE /* identifier under cursor */ +@@ -207,8 +205,6 @@ + + %token LAST_TOKEN + +- +- + /* *************************************************************** */ + + %union { +@@ -280,7 +276,7 @@ + %type <bbsymbolPositionLstPair> parameter_identifier_list identifier_list + %type <bbpositionLst> argument_expr_list argument_expr_list_opt + +-%type <bbtypeModif> type_specifier2 ++%type <bbtypeModif> type_specifier2 typeof_specifier + %type <bbtypeModif> struct_or_union_specifier struct_or_union_define_specifier + %type <bbtypeModif> enum_specifier enum_define_specifier + %type <bbtypeModif> type_name abstract_declarator abstract_declarator2 +@@ -751,6 +747,9 @@ declaration_specifiers0 + | type_specifier2 { + $$.d = typeSpecifier2($1.d); + } ++ | typeof_specifier { ++ $$.d = typeSpecifier2($1.d); ++ } + | declaration_modality_specifiers user_defined_type { + assert($2.d); + assert($2.d->sd); +@@ -765,9 +764,9 @@ declaration_specifiers0 + $$.d = $1.d; + declTypeSpecifier2($1.d,$2.d); + } +- | declaration_specifiers0 type_modality_specifier { ++ | declaration_modality_specifiers typeof_specifier { + $$.d = $1.d; +- declTypeSpecifier1($1.d,$2.d); ++ declTypeSpecifier2($1.d,$2.d); + } + | declaration_specifiers0 type_specifier1 { + $$.d = $1.d; +@@ -781,6 +780,10 @@ declaration_specifiers0 + $$.d = $1.d; + $$.d->b.storage = $2.d; + } ++ | declaration_specifiers0 type_modality_specifier { ++ $$.d = $1.d; ++ declTypeSpecifier1($1.d,$2.d); ++ } + | declaration_specifiers0 function_specifier { + $$.d = $1.d; + } +@@ -899,6 +902,15 @@ type_specifier2 + | enum_specifier /* { $$.d = $1.d; } */ + ; + ++typeof_specifier ++ : TYPEOF '(' type_name ')' { ++ $$.d = $3.d; ++ } ++ | TYPEOF '(' expr ')' { ++ $$.d = $3.d.t; ++ } ++ ; ++ + function_specifier + : INLINE + | _NORETURN +@@ -1174,6 +1186,9 @@ type_specifier_list0 + | type_specifier2 { + $$.d = typeSpecifier2($1.d); + } ++ | typeof_specifier { ++ $$.d = typeSpecifier2($1.d); ++ } + | type_mod_specifier_list user_defined_type { + assert($2.d); + assert($2.d->sd); +@@ -1189,6 +1204,10 @@ type_specifier_list0 + $$.d = $1.d; + declTypeSpecifier2($1.d,$2.d); + } ++ | type_mod_specifier_list typeof_specifier { ++ $$.d = $1.d; ++ declTypeSpecifier2($1.d,$2.d); ++ } + | type_specifier_list0 type_modality_specifier { + $$.d = $1.d; + declTypeSpecifier1($1.d,$2.d); +@@ -1919,6 +1938,3 @@ void makeCCompletions(char *s, int len, S_position *pos) { + + LICENSE_CHECK(); + } +- +- +- +diff --git a/src/globals.c b/src/globals.c +index ade4b4b..66ba837 100644 +--- a/src/globals.c ++++ b/src/globals.c +@@ -535,6 +535,7 @@ S_tokenNameIni s_tokenNameIniTab[] = { + {"register", REGISTER ,LAN_C | LAN_YACC | LAN_CCC}, + {"signed", SIGNED ,LAN_C | LAN_YACC | LAN_CCC}, + {"sizeof", SIZEOF ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"typeof", TYPEOF ,LAN_C | LAN_YACC | LAN_CCC}, + {"struct", STRUCT ,LAN_C | LAN_YACC | LAN_CCC}, + {"typedef", TYPEDEF ,LAN_C | LAN_YACC | LAN_CCC}, + {"union", UNION ,LAN_C | LAN_YACC | LAN_CCC}, +@@ -723,7 +724,8 @@ S_tokenNameIni s_tokenNameIniTab2[] = { + {"__threadd", _THREADLOCAL ,LAN_C | LAN_YACC | LAN_CCC}, + {"__restrict", RESTRICT ,LAN_C | LAN_YACC | LAN_CCC}, + {"__restrict__", RESTRICT ,LAN_C | LAN_YACC | LAN_CCC}, +- {"__extension__", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__typeof", TYPEOF ,LAN_C | LAN_YACC | LAN_CCC}, ++ {"__typeof__", TYPEOF ,LAN_C | LAN_YACC | LAN_CCC}, + {"__near", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__far", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, + {"__pascal", ANONYME_MOD ,LAN_C | LAN_YACC | LAN_CCC}, +diff --git a/src/javagram.y b/src/javagram.y +index 4dcf023..0f8ba9d 100644 +--- a/src/javagram.y ++++ b/src/javagram.y +@@ -156,7 +156,7 @@ + + /* c-special */ + %token TYPEDEF EXTERN AUTO REGISTER SIGNED UNSIGNED STRUCT UNION ENUM +-%token SIZEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN ++%token SIZEOF TYPEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN + /* hmm */ + %token ANONYME_MOD + +diff --git a/src/options.c b/src/options.c +index 2c40574..b02f578 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -40,9 +40,8 @@ static char *s_standardCOptions[] = { + #endif /*SBD*/ + #ifdef __mygnulinux__ /*SBD*/ + "-D__attribute__(xxx) ", ++ "-D__extension__ ", + "-D__alignof__(xxx) 8", +- "-Dtypeof(xxx) int", +- "-D__typeof__(xxx) int", + "-D__gnuc_va_list void", + "-D__builtin_va_list void", + "-D__builtin_va_start(v, l) ", +@@ -138,9 +137,8 @@ static char *s_standardCccOptions[] = { + "-I", "/usr/include/", + #ifdef __mygnulinux__ /*SBD*/ + "-D__attribute__(xxx) ", ++ "-D__extension__ ", + "-D__alignof__(xxx) 8", +- "-Dtypeof(xxx) int", +- "-D__typeof__(xxx) int", + "-D__gnuc_va_list void", + "-D__builtin_va_list void", + "-D__builtin_va_start(v, l) ", +diff --git a/src/yaccgram.y b/src/yaccgram.y +index 8773040..35a51f9 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -37,6 +37,7 @@ + assert(s_opt.taskRegime);\ + if (s_opt.taskRegime == RegimeEditServer) {\ + s_structRecordCompletionType = xxx;\ ++ assert(s_structRecordCompletionType);\ + }\ + } + #define SetStrCompl2(xxx) {\ +@@ -44,6 +45,7 @@ + if (s_opt.taskRegime == RegimeEditServer) {\ + if (xxx->m==TypePointer || xxx->m==TypeArray) {\ + s_structRecordCompletionType = xxx->next;\ ++ assert(s_structRecordCompletionType);\ + } else s_structRecordCompletionType = &s_errorModifier;\ + }\ + } +@@ -109,7 +111,7 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + + /* c-special */ + %token TYPEDEF EXTERN AUTO REGISTER SIGNED UNSIGNED STRUCT UNION ENUM +-%token SIZEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN ++%token SIZEOF TYPEOF RESTRICT _ATOMIC _BOOL _THREADLOCAL _NORETURN + /* hmm */ + %token ANONYME_MOD + +@@ -281,7 +283,7 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + %type <bbsymbolPositionLstPair> parameter_identifier_list identifier_list + %type <bbpositionLst> argument_expr_list argument_expr_list_opt + +-%type <bbtypeModif> type_specifier2 ++%type <bbtypeModif> type_specifier2 typeof_specifier + %type <bbtypeModif> struct_or_union_specifier struct_or_union_define_specifier + %type <bbtypeModif> enum_specifier enum_define_specifier + %type <bbtypeModif> type_name abstract_declarator abstract_declarator2 +@@ -476,7 +478,7 @@ any_token_not_perc_par: + | DOUBLE | ELSE | FLOAT | FOR | GOTO | IF | INT | LONG | RETURN | SHORT + | SWITCH | VOID | VOLATILE | WHILE + | TYPEDEF | EXTERN | AUTO | REGISTER | SIGNED | UNSIGNED | STRUCT | UNION +- | ENUM | SIZEOF | RESTRICT | _ATOMIC | _BOOL | _THREADLOCAL | _NORETURN ++ | ENUM | SIZEOF | TYPEOF | RESTRICT | _ATOMIC | _BOOL | _THREADLOCAL | _NORETURN + | ANONYME_MOD | TOKEN + | ABSTRACT | BOOLEAN | BYTE | CATCH | CLASS | EXTENDS | FINAL | FINALLY + | IMPLEMENTS | IMPORT | INSTANCEOF | INTERFACE | NATIVE | NEW +@@ -955,6 +957,9 @@ declaration_specifiers0 + | type_specifier2 { + $$.d = typeSpecifier2($1.d); + } ++ | typeof_specifier { ++ $$.d = typeSpecifier2($1.d); ++ } + | declaration_modality_specifiers user_defined_type { + assert($2.d); + assert($2.d->sd); +@@ -969,9 +974,9 @@ declaration_specifiers0 + $$.d = $1.d; + declTypeSpecifier2($1.d,$2.d); + } +- | declaration_specifiers0 type_modality_specifier { ++ | declaration_modality_specifiers typeof_specifier { + $$.d = $1.d; +- declTypeSpecifier1($1.d,$2.d); ++ declTypeSpecifier2($1.d,$2.d); + } + | declaration_specifiers0 type_specifier1 { + $$.d = $1.d; +@@ -985,6 +990,10 @@ declaration_specifiers0 + $$.d = $1.d; + $$.d->b.storage = $2.d; + } ++ | declaration_specifiers0 type_modality_specifier { ++ $$.d = $1.d; ++ declTypeSpecifier1($1.d,$2.d); ++ } + | declaration_specifiers0 function_specifier { + $$.d = $1.d; + } +@@ -1103,6 +1112,15 @@ type_specifier2 + | enum_specifier /* { $$.d = $1.d; } */ + ; + ++typeof_specifier ++ : TYPEOF '(' type_name ')' { ++ $$.d = $3.d; ++ } ++ | TYPEOF '(' expr ')' { ++ $$.d = $3.d.t; ++ } ++ ; ++ + function_specifier + : INLINE + | _NORETURN +@@ -1378,6 +1396,9 @@ type_specifier_list0 + | type_specifier2 { + $$.d = typeSpecifier2($1.d); + } ++ | typeof_specifier { ++ $$.d = typeSpecifier2($1.d); ++ } + | type_mod_specifier_list user_defined_type { + assert($2.d); + assert($2.d->sd); +@@ -1393,6 +1414,10 @@ type_specifier_list0 + $$.d = $1.d; + declTypeSpecifier2($1.d,$2.d); + } ++ | type_mod_specifier_list typeof_specifier { ++ $$.d = $1.d; ++ declTypeSpecifier2($1.d,$2.d); ++ } + | type_specifier_list0 type_modality_specifier { + $$.d = $1.d; + declTypeSpecifier1($1.d,$2.d); +-- +2.18.0 + diff --git a/0026-Add-showincludes-option.patch b/0026-Add-showincludes-option.patch new file mode 100644 index 000000000000..d66b041858ba --- /dev/null +++ b/0026-Add-showincludes-option.patch @@ -0,0 +1,98 @@ +From e0ddf603d23c41301a844a803a11d6d75e9150e4 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Tue, 1 Aug 2017 02:01:13 +0300 +Subject: [PATCH 26/33] Add -showincludes option + +--- + src/globals.c | 1 + + src/main.c | 2 ++ + src/proto.h | 1 + + src/yylex.c | 17 +++++++++++++++-- + 4 files changed, 19 insertions(+), 2 deletions(-) + +diff --git a/src/globals.c b/src/globals.c +index 66ba837..6cce897 100644 +--- a/src/globals.c ++++ b/src/globals.c +@@ -433,6 +433,7 @@ S_options s_initOpt = { + RegimeXref, + "nouser", // -user + 0, ++ 0, + 1, + 0, + 0, +diff --git a/src/main.c b/src/main.c +index 3ef299d..3f49131 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -91,6 +91,7 @@ static void usage(char *s) { + # ifdef DEBUG + fprintf(stdout,"\t-debug - produce debug trace of the execution\n"); + # endif ++ fprintf(stdout,"\t-showincludes - produce trace of include files\n"); + #if 0 + fprintf(stdout,"\t-typedefs - generate structure/enums typedefs\n"); + fprintf(stdout,"\t-str_fill - generate structure fills\n"); +@@ -1386,6 +1387,7 @@ static int processSOption(int *ii, int argc, char **argv) { + int i = * ii; + char *name, *val; + if (0) {} ++ else if (strcmp(argv[i],"-showincludes")==0) s_opt.showIncludes = 1; + else if (strcmp(argv[i],"-strict")==0) s_opt.strictAnsi = 1; + else if (strcmp(argv[i],"-str_fill")==0) s_opt.str_fill = 1; + else if (strcmp(argv[i],"-str_copy")==0) s_opt.str_copy = 1; +diff --git a/src/proto.h b/src/proto.h +index 02b08e6..0a8cb38 100644 +--- a/src/proto.h ++++ b/src/proto.h +@@ -1740,6 +1740,7 @@ struct options { + int taskRegime; + char *user; + int debug; ++ int showIncludes; + int cpp_comment; + int c_struct_scope; + int cxrefs; +diff --git a/src/yylex.c b/src/yylex.c +index 5cb5ff5..ae00881 100644 +--- a/src/yylex.c ++++ b/src/yylex.c +@@ -481,12 +481,12 @@ FILE *openInclude(char pchar, char *name, int nextFlag) { + char nn[MAX_FILE_NAME_SIZE]; + char rdir[MAX_FILE_NAME_SIZE]; + char *nnn; +- int nnlen,dlen,fdlen,nmlen,len,ii; ++ int nnlen,dlen,fdlen,nmlen,i; + er = NULL; r = NULL; + nmlen = strlen(name); + copyDir(rdir, cFile.fileName, &fdlen); + if (pchar!='<') { +-/*fprintf(dumpOut, "dlen == %d\n",dlen);*/ ++/*&fprintf(dumpOut, "dlen == %d\n",dlen);&*/ + strcpy(nn,normalizeFileName(name, rdir)); + /*&fprintf(dumpOut, "try to open %s\n",nn);&*/ + er = editorFindFile(nn); +@@ -518,6 +518,19 @@ FILE *openInclude(char pchar, char *name, int nextFlag) { + found: + nnn = normalizeFileName(nn, s_cwd); + strcpy(nn,nnn); ++ if ( (s_opt.taskRegime==RegimeXref ++ || s_opt.taskRegime==RegimeHtmlGenerate) ++ && s_opt.showIncludes) { ++ sprintf(tmpBuff, " "); ++ for(i=0; i<inStacki; i++) sprintf(tmpBuff+strlen(tmpBuff), " "); ++ sprintf(tmpBuff+strlen(tmpBuff),"%s", nn); ++ if (s_opt.xref2) { ++ ppcGenRecord(PPC_INFORMATION, tmpBuff, "\n"); ++ } else { ++ fprintf(dumpOut,"'%s'\n", tmpBuff); ++ } ++ fflush(dumpOut); ++ } + //&fprintf(dumpOut, "file %s opened\n",nn); + //&fprintf(dumpOut, "checking to %s \n",s_fileTab.tab[s_olOriginalFileNumber]->name); + pushNewInclude(r, er, nn, "\n"); +-- +2.18.0 + diff --git a/0027-Fix-if-defined-XXX-usage-references.patch b/0027-Fix-if-defined-XXX-usage-references.patch new file mode 100644 index 000000000000..a5de23e65ad9 --- /dev/null +++ b/0027-Fix-if-defined-XXX-usage-references.patch @@ -0,0 +1,25 @@ +From ee87a5bc25b8fd7b85d70239b39f095d76e2c992 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Tue, 1 Aug 2017 11:04:45 +0300 +Subject: [PATCH 27/33] Fix "#if defined XXX" usage references + +--- + src/yylex.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/yylex.c b/src/yylex.c +index ae00881..b77b195 100644 +--- a/src/yylex.c ++++ b/src/yylex.c +@@ -1034,7 +1034,7 @@ int cexpyylex() { + if (mm && memb->u.mbody == NULL) mm = 0; // undefined macro + assert(s_opt.taskRegime); + if (CX_REGIME()) { +- if (mm) addCxReference(&dd, &pos, UsageUsed,s_noneFileIndex, s_noneFileIndex); ++ if (mm) addCxReference(memb, &pos, UsageUsed,s_noneFileIndex, s_noneFileIndex); + } + /* following call sets uniyylval */ + res = cexpTranslateToken(CONSTANT, mm); +-- +2.18.0 + diff --git a/0028-Check-previous-link-names-for-enums-structs-unions.patch b/0028-Check-previous-link-names-for-enums-structs-unions.patch new file mode 100644 index 000000000000..60f90e4e754f --- /dev/null +++ b/0028-Check-previous-link-names-for-enums-structs-unions.patch @@ -0,0 +1,204 @@ +From b357126abc7baaa25f261cb84b926e3cd93a09ab Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Fri, 29 Sep 2017 19:58:47 +0300 +Subject: [PATCH 28/33] Check previous link names for enums/structs/unions + +--- + src/cxfile.c | 25 +++++++++++++++++++++++-- + src/cxref.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ + src/proto.h | 4 ++++ + src/semact.c | 4 ++++ + 4 files changed, 80 insertions(+), 2 deletions(-) + +diff --git a/src/cxfile.c b/src/cxfile.c +index 2eca78a..9c6b0b5 100644 +--- a/src/cxfile.c ++++ b/src/cxfile.c +@@ -1189,7 +1189,8 @@ static void cxrfSymbolName( int size, + } + s_inLastInfos.onLineRefMenuItem = cms; + //&fprintf(dumpOut,"check (%s) %s ols==%d\n", miscellaneousName[additionalArg], ddd->name, ols); +- if (ols || (additionalArg==CX_BY_PASS&&byPassAcceptableSymbol(ddd)) ++ if (ols || (additionalArg==CX_BY_PASS&&byPassAcceptableSymbol(ddd) ++ || (additionalArg==CX_BY_PASS2&&byPassAcceptableSymbol2(ddd))) + ) { + s_inLastInfos.onLineReferencedSym = si; + s_inLastInfos.onLineRefIsBestMatchFlag = (ols == 2); +@@ -1250,7 +1251,8 @@ static void cxrfReference( int size, + S_symbolRefItem *memb; + S_usageBits usageBits; + int ii,file,line,coll,usage,sym,addfl,reqAcc; +- int copyrefFl; ++ int copyrefFl,nlen; ++ char *nn; + assert(ri == CXFI_REFERENCE); + usage = s_inLastInfos.counter[CXFI_USAGE]; + reqAcc = s_inLastInfos.counter[CXFI_REQ_ACCESS]; +@@ -1352,6 +1354,13 @@ static void cxrfReference( int size, + &s_olcxCurrentUser->browserStack.top->hkSelectedSym, + 1, 1, 0, usage,0,&s_noPos, UsageNone); + } ++ } else if (additionalArg == CX_BY_PASS2) { ++ if (POSITION_EQ(s_cxRefPos, pos)) { ++ nlen = strlen(s_inLastInfos.symbolTab[sym]->name); ++ OLCX_ALLOCC(nn, nlen+1, char); ++ strcpy(nn, s_inLastInfos.symbolTab[sym]->name); ++ s_olcxCurrentUser->browserStack.top->hkSelectedSym->s.name = nn; ++ } + } else if (1 + /*& + s_opt.keep_old +@@ -1622,6 +1631,18 @@ S_cxScanFileFunctionLink s_cxByPassFunTab[]={ + {-1,NULL, 0}, + }; + ++S_cxScanFileFunctionLink s_cxByPassFunTab2[]={ ++ {CXFI_SINGLE_RECORDS,cxrfSetSingleRecords, 0}, ++ {CXFI_VERSION, cxrfVersionCheck, 0}, ++ {CXFI_FILE_NAME,cxrfFileName, CX_JUST_READ}, ++ {CXFI_SOURCE_INDEX, cxrfSourceIndex, CX_JUST_READ}, ++ {CXFI_SYM_NAME,cxrfSymbolName, CX_BY_PASS2}, ++ {CXFI_REFERENCE,cxrfReference, CX_BY_PASS2}, ++ {CXFI_CLASS_EXT,cxrfSubClass, CX_JUST_READ}, ++ {CXFI_REFNUM,cxrfRefNum, 0}, ++ {-1,NULL, 0}, ++}; ++ + S_cxScanFileFunctionLink s_cxSymbolLoadMenuRefs[]={ + {CXFI_SINGLE_RECORDS,cxrfSetSingleRecords, 0}, + {CXFI_VERSION, cxrfVersionCheck, 0}, +diff --git a/src/cxref.c b/src/cxref.c +index 2e91f37..6042d8a 100644 +--- a/src/cxref.c ++++ b/src/cxref.c +@@ -849,6 +849,44 @@ S_reference * addCxReference(S_symbol *p, S_position *pos, int usage, int vFunCl + return(addCxReferenceNew(p, pos, &ub, vFunCl, vApplCl)); + } + ++void checkPreviousCxLinkNames(S_symbol *p, S_position *pos) ++{ ++ int ii,category,scope,storage,deleted; ++ char *ss; ++ S_symbolRefItem *memb,*memb2,ri,ri2; ++ S_reference *rr,**rrplace; ++ S_olSymbolsMenu *mm,**mmplace,ddd; ++ getSymbolCxrefCategories(p, &category, &scope, &storage); ++ FILL_symbolRefItemBits(&ri.b,p->b.symType,storage,scope, ++ p->b.accessFlags,category,0); ++ FILL_symbolRefItem(&ri,p->linkName, ++ 0, // cxFileHashNumber(p->linkName), ++ s_noneFileIndex,s_noneFileIndex,ri.b,NULL,NULL); ++ p->pos = *pos; ++ setGlobalFileDepNames(p->name, p, MEM_XX); ++ if (refTabIsMember(&s_cxrefTab, &ri, &ii, &memb)) { ++ deleted = refTabDeleteExact(&s_cxrefTab, memb); ++ assert(deleted); ++ ri2 = ri; ri2.name = p->linkName; ++ if (!refTabIsMember(&s_cxrefTab, &ri2, &ii, &memb2)) { ++ CX_ALLOCC(ss, strlen(p->linkName)+1, char); ++ strcpy(ss, p->linkName); ++ memb2 = memb; ++ memb2->name = ss; ++ refTabSet(&s_cxrefTab, memb2, ii); ++ } ++ else { ++ while (memb->refs != NULL) { ++ rr = memb->refs; memb->refs = memb->refs->next; ++ SORTED_LIST_PLACE2(rrplace, S_reference, *rr, &memb2->refs); ++ if (*rrplace == NULL || SORTED_LIST_NEQ((*rrplace), *rr)) { ++ LIST_CONS(rr,(*rrplace)); ++ } ++ } ++ } ++ } ++} ++ + void addTrivialCxReference(char *name,int symType,int storage,S_position *pos,int usage) { + S_symbol ss; + S_symbolBits bb; +@@ -3634,6 +3672,7 @@ void olCreateSelectionMenu(int command) { + LIST_SORT(S_olSymbolsMenu, rstack->hkSelectedSym, olMenuHashFileNumLess); + ss = rstack->hkSelectedSym; + while (ss!=NULL) { ++ readOneAppropReferenceFile(ss->s.name, s_cxByPassFunTab2); + readOneAppropReferenceFile(ss->s.name, s_cxSymbolMenuCreationTab); + fnum = cxFileHashNumber(ss->s.name); + //&fprintf(dumpOut,"file %d readed\n", fnum); +@@ -5177,6 +5216,16 @@ int byPassAcceptableSymbol(S_symbolRefItem *p) { + return(1); + } + ++int byPassAcceptableSymbol2(S_symbolRefItem *p) { ++ int nlen,len; ++ char *nn, *nnn; ++ GET_NUDE_NAME(p->name, nn, len); ++ GET_NUDE_NAME(s_olcxCurrentUser->browserStack.top->hkSelectedSym->s.name, nnn, nlen); ++ if (len != nlen) return(0); ++ if (strncmp(nn, nnn, len)) return(0); ++ return(1); ++} ++ + // DOES NOT WORK!!! because it is not loading references from current file + // because cxfile does not know I am in s_opt.cxrefs==OLO_PUSH_NAME + static void oloPushByNameIfNothingPushed() { +diff --git a/src/proto.h b/src/proto.h +index 0a8cb38..de83530 100644 +--- a/src/proto.h ++++ b/src/proto.h +@@ -37,6 +37,7 @@ enum miscellaneous { /* misc. constants */ + CX_HTML_SECOND_PASS, + CX_MENU_CREATION, + CX_BY_PASS, ++ CX_BY_PASS2, + HTML_GEN, + HTML_NO_GEN, + MEM_ALLOC_ON_SM, +@@ -2121,6 +2122,7 @@ S_reference *duplicateReference C_ARG((S_reference *r)); + S_reference * addCxReferenceNew C_ARG((S_symbol *p, S_position *pos, S_usageBits *ub, int vFunCl, int vApplCl)); + S_reference * addCxReference C_ARG((S_symbol *p, S_position *pos, int usage, int vFunClass,int vApplClass)); + S_reference *addSpecialFieldReference C_ARG((char *name, int storage, int fnum, S_position *p, int usage)); ++void checkPreviousCxLinkNames(S_symbol *p, S_position *pos); + void addClassTreeHierarchyReference C_ARG((int fnum, S_position *p, int usage)); + void addCfClassTreeHierarchyRef C_ARG((int fnum, int usage)); + void addTrivialCxReference C_ARG((char *name, int symType, int storage, S_position *pos, int usage)); +@@ -2156,6 +2158,7 @@ int isInRefList C_ARG((S_reference *list, + )); + char *getXrefEnvironmentValue C_ARG(( char *name )); + int byPassAcceptableSymbol C_ARG((S_symbolRefItem *p)); ++int byPassAcceptableSymbol2 C_ARG((S_symbolRefItem *p)); + int itIsSymbolToPushOlRefences C_ARG((S_symbolRefItem *p, S_olcxReferences *rstack, S_olSymbolsMenu **rss, int checkSelFlag)); + void olcxAddReferenceToOlSymbolsMenu C_ARG((S_olSymbolsMenu *cms, S_reference *rr, + int bestFitTlag)); +@@ -2225,6 +2228,7 @@ void scanReferenceFiles C_ARG((char *fname, S_cxScanFileFunctionLink *scanFunTab + extern S_cxScanFileFunctionLink s_cxScanFileTab[]; + extern S_cxScanFileFunctionLink s_cxFullScanFunTab[]; + extern S_cxScanFileFunctionLink s_cxByPassFunTab[]; ++extern S_cxScanFileFunctionLink s_cxByPassFunTab2[]; + extern S_cxScanFileFunctionLink s_cxSymbolMenuCreationTab[]; + extern S_cxScanFileFunctionLink s_cxSymbolLoadMenuRefs[]; + extern S_cxScanFileFunctionLink s_cxScanFunTabFor2PassMacroUsage[]; +diff --git a/src/semact.c b/src/semact.c +index cb3f623..9b3bc09 100644 +--- a/src/semact.c ++++ b/src/semact.c +@@ -924,6 +924,8 @@ S_typeModifiers *simpleStrUnionSpecifier( S_idIdent *typeName, + pp->u.s->stype.u.t = pp; + setGlobalFileDepNames(id->name, pp, MEM_XX); + addSymbol(pp, s_symTab); ++ } else if (IS_DEFINITION_USAGE(usage)) { ++ checkPreviousCxLinkNames(pp, &id->p); + } + addCxReference(pp, &id->p, usage,s_noneFileIndex, s_noneFileIndex); + return(&pp->u.s->stype); +@@ -1078,6 +1080,8 @@ S_typeModifiers *simpleEnumSpecifier(S_idIdent *id, int usage) { + *pp = p; + setGlobalFileDepNames(id->name, pp, MEM_XX); + addSymbol(pp, s_symTab); ++ } else if (IS_DEFINITION_USAGE(usage)) { ++ checkPreviousCxLinkNames(pp, &id->p); + } + addCxReference(pp, &id->p, usage,s_noneFileIndex, s_noneFileIndex); + return(crSimpleEnumType(pp,TypeEnum)); +-- +2.18.0 + diff --git a/0029-Parse-obsolete-GCC-structs-unions-initializer-list.patch b/0029-Parse-obsolete-GCC-structs-unions-initializer-list.patch new file mode 100644 index 000000000000..3f2f9e706a80 --- /dev/null +++ b/0029-Parse-obsolete-GCC-structs-unions-initializer-list.patch @@ -0,0 +1,136 @@ +From 0a22a85f7712b645bfc0ccab8d8c970081bb8152 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Thu, 16 Nov 2017 04:33:47 +0000 +Subject: [PATCH 29/33] Parse obsolete GCC structs/unions initializer-list + syntax + +--- + src/cgram.y | 27 ++++++++++++++++----------- + src/yaccgram.y | 27 ++++++++++++++++----------- + 2 files changed, 32 insertions(+), 22 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index 1ef4600..ea4c6ba 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -255,7 +255,7 @@ + %type <bbidIdent> str_rec_identifier STRUCT UNION struct_or_union + %type <bbidIdent> user_defined_type TYPE_NAME + %type <bbidIdent> designator designator_list +-%type <bbidlist> designation_opt initializer initializer_list initializer_list_opt eq_initializer_opt ++%type <bbidlist> initializer initializer0 initializer_list initializer_list_opt eq_initializer_opt + %type <bbinteger> assignment_operator + %type <bbinteger> pointer CONSTANT _ncounter_ _nlabel_ _ngoto_ _nfork_ + %type <bbunsign> storage_class_specifier type_specifier1 +@@ -1412,24 +1412,28 @@ initializer_list_opt: { + ; + + initializer_list +- : Sv_tmp designation_opt initializer { ++ : Sv_tmp initializer0 { + $$.d = $2.d; +- if ($$.d!=NULL) $$.d->down = $3.d; + tmpWorkMemoryi = $1.d; + } +- | initializer_list ',' Sv_tmp designation_opt initializer { +- LIST_APPEND(S_idIdentList, $1.d, $4.d); +- if ($4.d!=NULL) $4.d->down = $5.d; ++ | initializer_list ',' Sv_tmp initializer0 { ++ $$.d = $1.d; ++ LIST_APPEND(S_idIdentList, $$.d, $4.d); + tmpWorkMemoryi = $3.d; + } + ; + +-designation_opt: { +- $$.d = NULL; ++initializer0 ++ : initializer { ++ $$.d = $1.d; + } +- | designator_list '=' { ++ | designator_list '=' initializer { + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, NULL,NULL); ++ FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); ++ } ++ | str_rec_identifier ':' initializer { /* GNU-extension*/ ++ $$.d = StackMemAlloc(S_idIdentList); ++ FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); + } + ; + +@@ -1438,7 +1442,8 @@ designator_list + $$.d = $1.d; + } + | designator_list designator { +- LIST_APPEND(S_idIdent, $1.d, $2.d); ++ $$.d = $1.d; ++ LIST_APPEND(S_idIdent, $$.d, $2.d); + } + ; + +diff --git a/src/yaccgram.y b/src/yaccgram.y +index 35a51f9..d5f0da6 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -262,7 +262,7 @@ static void addYaccSymbolReference C_ARG((S_idIdent *name, int usage)); + %type <bbidIdent> user_defined_type TYPE_NAME lexem + %type <bbinteger> pointer CONSTANT rule_body + %type <bbidIdent> designator designator_list +-%type <bbidlist> designation_opt initializer initializer_list initializer_list_opt eq_initializer_opt ++%type <bbidlist> initializer initializer0 initializer_list initializer_list_opt eq_initializer_opt + %type <bbinteger> assignment_operator + %type <bbinteger> pointer CONSTANT _ncounter_ _nlabel_ _ngoto_ _nfork_ + %type <bbunsign> storage_class_specifier type_specifier1 +@@ -1622,24 +1622,28 @@ initializer_list_opt: { + ; + + initializer_list +- : Sv_tmp designation_opt initializer { ++ : Sv_tmp initializer0 { + $$.d = $2.d; +- if ($$.d!=NULL) $$.d->down = $3.d; + tmpWorkMemoryi = $1.d; + } +- | initializer_list ',' Sv_tmp designation_opt initializer { +- LIST_APPEND(S_idIdentList, $1.d, $4.d); +- if ($4.d!=NULL) $4.d->down = $5.d; ++ | initializer_list ',' Sv_tmp initializer0 { ++ $$.d = $1.d; ++ LIST_APPEND(S_idIdentList, $$.d, $4.d); + tmpWorkMemoryi = $3.d; + } + ; + +-designation_opt: { +- $$.d = NULL; ++initializer0 ++ : initializer { ++ $$.d = $1.d; + } +- | designator_list '=' { ++ | designator_list '=' initializer { + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, NULL,NULL); ++ FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); ++ } ++ | str_rec_identifier ':' initializer { /* GNU-extension*/ ++ $$.d = StackMemAlloc(S_idIdentList); ++ FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); + } + ; + +@@ -1648,7 +1652,8 @@ designator_list + $$.d = $1.d; + } + | designator_list designator { +- LIST_APPEND(S_idIdent, $1.d, $2.d); ++ $$.d = $1.d; ++ LIST_APPEND(S_idIdent, $$.d, $2.d); + } + ; + +-- +2.18.0 + diff --git a/0030-Fix-stdop-and-optinclude-options.patch b/0030-Fix-stdop-and-optinclude-options.patch new file mode 100644 index 000000000000..495c5da69ea3 --- /dev/null +++ b/0030-Fix-stdop-and-optinclude-options.patch @@ -0,0 +1,198 @@ +From 5a547726aa5d145fd160035bedba1b51041a9534 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Mon, 12 Feb 2018 00:07:19 +0000 +Subject: [PATCH] Fix -stdop and -optinclude options + +--- + src/head2.h | 2 +- + src/main.c | 27 ++++++++++++++++----------- + src/options.c | 24 ++++++++++++++++++++---- + doc/xref.man | 7 ++++++- + 4 files changed, 42 insertions(+), 16 deletions(-) + +diff --git a/src/head2.h b/src/head2.h +index 4a620a1..0ab24b7 100644 +--- a/src/head2.h ++++ b/src/head2.h +@@ -22,7 +22,7 @@ + + #define SIZE_ppMemory 20000 /* macro args name in define */ + #define SIZE_mbMemory 2000000 /* pending macro expansions */ +-#define SIZE_opiMemory 150000 /* memory used to store options strings */ ++#define SIZE_opiMemory 300000 /* memory used to store options strings */ + #define SIZE_workMemory 10000000 /* parsing stack memory */ + #define SIZE_tmpWorkMemory 400000 /* additional tmp parsing stack memory */ + #define SIZE_ftMemory 8000000 /* memory for file (and class) table */ +diff --git a/src/main.c b/src/main.c +index 3f49131..5a8fef5 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -63,7 +63,7 @@ + fprintf(stdout,"\t-filescaseunsensitive - file names are case unsensitive\n"); + fprintf(stdout,"\t-csuffixes=<paths> - list of C files suffixes separated by : (or ;)"); + fprintf(stdout,"\t-javasuffixes=<paths> - list of Java files suffixes separated by : (or ;)\n"); +- fprintf(stdout,"\t-stdop <file> - read options from <file>\n"); ++ fprintf(stdout,"\t-optinclude <file> (or -stdop <file>) - read options from <file>\n"); + fprintf(stdout,"\t-no_cpp_comment - C++ like comments // not admitted\n"); + fprintf(stdout,"\t-license=<string> - license string\n"); + #if 0 +@@ -356,7 +356,6 @@ void xrefSetenv(char *name, char *val) { + if (j==n) sge->num ++; + } + +- + int mainHandleSetOption( int argc, char **argv, int i ) { + S_setGetEnv *sge; + char *name, *val; +@@ -370,13 +369,19 @@ int mainHandleSetOption( int argc, char **argv, int i ) { + return(i); + } + +-static int mainHandleIncludeOption(int argc, char **argv, int i) { ++static int mainHandleIncludeOption(int argc, char **argv, int i, int infilesFlag) { + int nargc,aaa; + char **nargv; ++ FILE *ff; ++ char realSection[MAX_FILE_NAME_SIZE]; + NEXT_FILE_ARG(); + s_opt.stdopFlag = 1; +- readOptionFile(argv[i],&nargc,&nargv,"",NULL); +- processOptions(nargc, nargv, INFILES_DISABLED); ++ ff = fopen(argv[i],"r"); ++ if (ff==NULL) fatalError(ERR_CANT_OPEN,argv[i], XREF_EXIT_ERR); ++ readOptionFromFile(ff,&nargc,&nargv,MEM_ALLOC_ON_PP,s_input_file_name,s_opt.project,realSection); ++ fclose(ff); ++ processOptions(nargc, nargv, infilesFlag); ++ reInitCwd("",realSection); + s_opt.stdopFlag = 0; + return(i); + } +@@ -887,7 +892,7 @@ static int processNOption(int *ii, int argc, char **argv) { + return(1); + } + +-static int processOOption(int *ii, int argc, char **argv) { ++static int processOOption(int *ii, int argc, char **argv, int infilesFlag) { + int i = * ii; + if (0) {} + else if (strncmp(argv[i],"-oocheckbits=",13)==0) { +@@ -1177,4 +1182,7 @@ static int processOOption(int *ii, int argc, char **argv) { + sscanf(argv[i]+16,"%d",&s_opt.filterValue); + } ++ else if (strcmp(argv[i],"-optinclude")==0) { ++ i = mainHandleIncludeOption(argc, argv, i, infilesFlag); ++ } + else if (strcmp(argv[i],"-o")==0) { + NEXT_FILE_ARG(); +@@ -1383,7 +1388,7 @@ static int processROption(int *ii, int argc, char **argv, int infilesFlag) { + return(1); + } + +-static int processSOption(int *ii, int argc, char **argv) { ++static int processSOption(int *ii, int argc, char **argv, int infilesFlag) { + int i = * ii; + char *name, *val; + if (0) {} +@@ -1408,7 +1413,7 @@ static int processSOption(int *ii, int argc, char **argv) { + xrefSetenv("-sourcepath", s_opt.sourcePath); + } + else if (strcmp(argv[i],"-stdop")==0) { +- i = mainHandleIncludeOption(argc, argv, i); ++ i = mainHandleIncludeOption(argc, argv, i, infilesFlag); + } + else if (strcmp(argv[i],"-set")==0) { + i = mainHandleSetOption(argc, argv, i); +@@ -1650,7 +1655,7 @@ void processOptions(int argc, char **argv, int infilesFlag) { + break; + case 'n': case 'N': processed = processNOption(&i, argc, argv); + break; +- case 'o': case 'O': processed = processOOption(&i, argc, argv); ++ case 'o': case 'O': processed = processOOption(&i, argc, argv, infilesFlag); + break; + case 'p': case 'P': processed = processPOption(&i, argc, argv); + break; +@@ -1658,7 +1663,7 @@ void processOptions(int argc, char **argv, int infilesFlag) { + break; + case 'r': case 'R': processed = processROption(&i, argc, argv, infilesFlag); + break; +- case 's': case 'S': processed = processSOption(&i, argc, argv); ++ case 's': case 'S': processed = processSOption(&i, argc, argv, infilesFlag); + break; + case 't': case 'T': processed = processTOption(&i, argc, argv); + break; +diff --git a/src/options.c b/src/options.c +index b02f578..36987cb 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -560,8 +560,9 @@ static void processSectionMarker(char *ttt,int i,char *project,char *section, + int readOptionFromFile(FILE *ff, int *nargc, char ***nargv, int memFl, + char *sectionFile,char *project, char *resSection) { + char tt[MAX_OPTION_LEN]; +- int len,argc,i,c,isActiveSect,isActivePass,res,sl,passn=0; +- char **aargv,*argv[MAX_STD_ARGS]; ++ int len,argc,dfargc,i,c,isActiveSect,isActivePass,res,sl,passn=0; ++ char **aargv,**dfargv,*argv[MAX_STD_ARGS],dffsect[MAX_FILE_NAME_SIZE]; ++ FILE *ff2; + argc = 1; res = 0; isActiveSect = isActivePass = 1; aargv=NULL; + resSection[0]=0; + if (memFl==MEM_ALLOC_ON_SM) SM_INIT(optMemory); +@@ -573,7 +574,22 @@ int readOptionFromFile(FILE *ff, int *nargc, char ***nargv, int memFl, + expandEnvironmentVariables(tt+1,MAX_OPTION_LEN,&len,GLOBAL_ENV_ONLY); + //&fprintf(dumpOut,"expanded '%s'\n", tt); + processSectionMarker(tt,len+1,project,sectionFile,&isActiveSect,resSection); +- } else if (isActiveSect && strncmp(tt,"-pass",5)==0) { ++ } else if (isActiveSect && (strncmp(tt,"-optinclude",11)==0 || strncmp(tt, "-stdop",6)==0)) { ++ c = getOptionFromFile(ff,tt,MAX_OPTION_LEN,&len); ++ expandEnvironmentVariables(tt,MAX_OPTION_LEN,&len,DEFAULT_VALUE); ++ ff2 = fopen(tt, "r"); ++ if (ff2==NULL) fatalError(ERR_CANT_OPEN,tt, XREF_EXIT_ERR); ++ if (readOptionFromFile(ff2,&dfargc,&dfargv,memFl,sectionFile,project,dffsect)) { ++ res = 1; ++ } ++ fclose(ff2); ++ for(i=1; i<dfargc; i++) { ++ argv[argc] = dfargv[i]; ++ if (argc < MAX_STD_ARGS-1) argc++; ++ } ++ if (dffsect[0]!=0) strcpy(resSection,dffsect); ++ } ++ else if (isActiveSect && strncmp(tt,"-pass",5)==0) { + sscanf(tt+5, "%d", &passn); + if (passn==s_currCppPass || s_currCppPass==ANY_CPP_PASS) { + isActivePass = 1; +@@ -584,7 +600,7 @@ int readOptionFromFile(FILE *ff, int *nargc, char ***nargv, int memFl, + } else if (strncmp(tt,"-license=",9)==0) { + // special care is given to the -license option + strcpy(s_opt.licenseString, tt+9); +-//& strcpy(s_initOpt.licenseString, tt+9); // why not ? ++//& strcpy(s_initOpt.licenseString, tt+9); // why not ? + s_expTime = 0; // reinitialize it to be reloaded + } else if (strcmp(tt,"-set")==0 && ACTIVE_OPTION() + && memFl!=MEM_NO_ALLOC) { +diff -u a/doc/xref.man b/doc/xref.man +--- a/doc/xref.man ++++ b/doc/xref.man +@@ -144,6 +144,11 @@ + using relative path, it is considered relative to the currently + parsed file directory. + .TP ++.B \-include file ++Process file ++.I file ++as input before processing the regular input file. ++.TP + .BI "\-D" "name"\c + \& + Predefine \c +@@ -523,7 +528,7 @@ + that all generated HTML files will be compressed and the links are + correctly generated to those compressed files. + .TP +-.B \-include file (or \-stdop file) ++.B \-optinclude file (or \-stdop file) + This option causes that the file `\|\c + .I file\c + \&\|' is read and scanned for further options. When used in an .xrefrc file +-- +2.18.0 + diff --git a/0031-Fix-parsing-arrays-structs-unions-initializer-list.patch b/0031-Fix-parsing-arrays-structs-unions-initializer-list.patch new file mode 100644 index 000000000000..b5ab2d095ce8 --- /dev/null +++ b/0031-Fix-parsing-arrays-structs-unions-initializer-list.patch @@ -0,0 +1,405 @@ +From 8896bc79d312a078287ad3b661152d99c55bdb37 Mon Sep 17 00:00:00 2001 +From: litvin <litvindev@gmail.com> +Date: Thu, 31 May 2018 18:32:40 +0300 +Subject: [PATCH 31/33] Fix parsing arrays/structs/unions initializer-list + +--- + src/cgram.y | 12 ++++++------ + src/complet.c | 6 +++--- + src/javagram.y | 8 ++++---- + src/jsemact.c | 16 ++++++++-------- + src/proto.h | 5 +++++ + src/semact.c | 45 ++++++++++++++++++++++++++++----------------- + src/yaccgram.y | 12 ++++++------ + 7 files changed, 60 insertions(+), 44 deletions(-) + +diff --git a/src/cgram.y b/src/cgram.y +index ea4c6ba..298c9e4 100644 +--- a/src/cgram.y ++++ b/src/cgram.y +@@ -398,7 +398,7 @@ postfix_expr + } + | postfix_expr {SetStrCompl1($1.d.t);} '.' str_rec_identifier { + S_symbol *rec=NULL; +- $$.d.r = findStrRecordFromType($1.d.t, $4.d, &rec, CLASS_TO_ANY); ++ $$.d.r = findStrRecordFromType($1.d.t, $4.d, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_ANY); + assert(rec); + $$.d.t = rec->u.type; + assert($$.d.t); +@@ -408,7 +408,7 @@ postfix_expr + S_symbol *rec=NULL; + $$.d.r = NULL; + if ($1.d.t->m==TypePointer || $1.d.t->m==TypeArray) { +- $$.d.r = findStrRecordFromType($1.d.t->next, $4.d, &rec, CLASS_TO_ANY); ++ $$.d.r = findStrRecordFromType($1.d.t->next, $4.d, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_ANY); + assert(rec); + $$.d.t = rec->u.type; + } else $$.d.t = &s_errorModifier; +@@ -1429,11 +1429,11 @@ initializer0 + } + | designator_list '=' initializer { + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); ++ FILL_idIdentList($$.d, *$1.d, NULL, TypeDefault, $3.d,NULL); + } + | str_rec_identifier ':' initializer { /* GNU-extension*/ + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); ++ FILL_idIdentList($$.d, *$1.d, NULL, TypeDefault, $3.d,NULL); + } + ; + +@@ -1450,11 +1450,11 @@ designator_list + designator + : '[' constant_expr ']' { + $$.d = StackMemAlloc(S_idIdent); +- FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ FILL_idIdent($$.d, NULL, NULL, s_noPos, NULL); + } + | '[' constant_expr ELIPSIS constant_expr ']' { + $$.d = StackMemAlloc(S_idIdent); +- FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ FILL_idIdent($$.d, NULL, NULL, s_noPos, NULL); + } + | '.' str_rec_identifier { + $$.d = StackMemAlloc(S_idIdent); +diff --git a/src/complet.c b/src/complet.c +index dd1f09d..d10edee 100644 +--- a/src/complet.c ++++ b/src/complet.c +@@ -924,7 +924,7 @@ static void completeRecordsNames( + //&} else { + //& visibCheck = VISIB_CHECK_NO; + //&} +- rr = findStrRecordSym(&rfs, NULL, &r, classification, accCheck, visibCheck); ++ rr = findStrRecordSym(&rfs, NULL, &r, SEARCH_IN_MEMBERS_NO, classification, accCheck, visibCheck); + if (rr != RETURN_OK) break; + if (constructorOpt==StorageConstructor && rfs.currClass!=s) break; + /* because constructors are not inherited */ +@@ -1104,7 +1104,7 @@ static char *spComplFindNextRecord(S_exprTokenType *tok) { + assert(s->u.s); + iniFind(s, &rfs); + for(;;) { +- rr = findStrRecordSym(&rfs, NULL, &r, CLASS_TO_ANY, ACC_CHECK_YES, VISIB_CHECK_YES); ++ rr = findStrRecordSym(&rfs, NULL, &r, SEARCH_IN_MEMBERS_NO, CLASS_TO_ANY, ACC_CHECK_YES, VISIB_CHECK_YES); + if (rr != RETURN_OK) break; + assert(r); + cname = r->name; +@@ -1416,7 +1416,7 @@ void javaHintCompleteMethodParameters(S_completions *c) { + vlevel,0,NULL,vFunCl); + processName(r->name, &compLine, 0, (void*) c); + } +- rr = findStrRecordSym(rfs, mname, &r, CLASS_TO_METHOD, accCheck, visibCheck); ++ rr = findStrRecordSym(rfs, mname, &r, SEARCH_IN_MEMBERS_NO, CLASS_TO_METHOD, accCheck, visibCheck); + } while (rr == RETURN_OK); + if (c->ai != 0) { + c->comPrefix[0]=0; +diff --git a/src/javagram.y b/src/javagram.y +index 0f8ba9d..de5dc0c 100644 +--- a/src/javagram.y ++++ b/src/javagram.y +@@ -1521,7 +1521,7 @@ FieldDeclaration: + } + //&javaSetFieldLinkName(p); + iniFind(clas, &rfs); +- if (findStrRecordSym(&rfs, p->name, &memb, CLASS_TO_ANY, ++ if (findStrRecordSym(&rfs, p->name, &memb, SEARCH_IN_MEMBERS_NO, CLASS_TO_ANY, + ACC_CHECK_NO,VISIB_CHECK_NO) == RETURN_NOT_FOUND) { + assert(clas->u.s); + LIST_APPEND(S_symbol, clas->u.s->records, p); +@@ -3517,7 +3517,7 @@ FieldAccess: + $$.d.pp = $1.d.pp; + if ($1.d.t->m == TypeStruct) { + javaLoadClassSymbolsFromFile($1.d.t->u.t); +- $$.d.r = findStrRecordFromType($1.d.t, $3.d, &rec, CLASS_TO_EXPR); ++ $$.d.r = findStrRecordFromType($1.d.t, $3.d, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_EXPR); + assert(rec); + $$.d.t = rec->u.type; + } else if (s_language == LAN_JAVA) { +@@ -3543,7 +3543,7 @@ FieldAccess: + ss = javaCurrentSuperClass(); + if (ss != &s_errorSymbol && ss->b.symType!=TypeError) { + javaLoadClassSymbolsFromFile(ss); +- $$.d.r = findStrRecordFromSymbol(ss, $3.d, &rec, CLASS_TO_EXPR, $1.d); ++ $$.d.r = findStrRecordFromSymbol(ss, $3.d, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_EXPR, $1.d); + assert(rec); + $$.d.t = rec->u.type; + } else { +@@ -3567,7 +3567,7 @@ FieldAccess: + if (ss != &s_errorSymbol && ss->b.symType!=TypeError) { + javaLoadClassSymbolsFromFile(ss); + ss = javaGetSuperClass(ss); +- $$.d.r = findStrRecordFromSymbol(ss, $5.d, &rec, CLASS_TO_EXPR, NULL); ++ $$.d.r = findStrRecordFromSymbol(ss, $5.d, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_EXPR, NULL); + assert(rec); + $$.d.t = rec->u.type; + } else { +diff --git a/src/jsemact.c b/src/jsemact.c +index 43e4ff9..334dda4 100644 +--- a/src/jsemact.c ++++ b/src/jsemact.c +@@ -923,7 +923,7 @@ static int findTopLevelNameInternal( + *rscope = cscope; + } + //&fprintf(dumpOut," %s %s\n", miscellaneousName[classif], miscellaneousName[accCheck]); +- res = findStrRecordSym(resRfs, name, resMemb, classif, accCheck, visibCheck); ++ res = findStrRecordSym(resRfs, name, resMemb, SEARCH_IN_MEMBERS_NO, classif, accCheck, visibCheck); + } + return(res); + } +@@ -1452,7 +1452,7 @@ int javaClassifyAmbiguousName( + } else { + javaLoadClassSymbolsFromFile(pstr); + rf = findStrRecordSym(iniFind(pstr,rfs), name->idi.name, str, +- classif, ACC_CHECK_NO, VISIB_CHECK_NO); ++ SEARCH_IN_MEMBERS_NO, classif, ACC_CHECK_NO, VISIB_CHECK_NO); + *expr = (*str)->u.type; + if (rf == RETURN_OK) { + name->nameType = TypeExpression; +@@ -1486,7 +1486,7 @@ int javaClassifyAmbiguousName( + } else { + javaLoadClassSymbolsFromFile(pexpr->u.t); + rr = findStrRecordSym(iniFind(pexpr->u.t,rfs), name->idi.name, +- str, classif, ACC_CHECK_NO, VISIB_CHECK_NO); ++ str, SEARCH_IN_MEMBERS_NO, classif, ACC_CHECK_NO, VISIB_CHECK_NO); + if (rr == RESULT_OK) { + if ((s_opt.ooChecksBits & OOC_ALL_CHECKS)==0 + || javaRecordVisibleAndAccessible(rfs, rfs->baseClass, rfs->currClass, *str)) { +@@ -2237,7 +2237,7 @@ static S_typeModifiers *javaMethodInvocation( + //&sprintf(tmpBuff,"applicable: %s of %s\n",memb->linkName,rfs->currClass->linkName);ppcGenTmpBuff(); + } + rr = findStrRecordSym(rfs, name->name, &memb, +- CLASS_TO_METHOD, ACC_CHECK_NO, VISIB_CHECK_NO); ++ SEARCH_IN_MEMBERS_NO, CLASS_TO_METHOD, ACC_CHECK_NO, VISIB_CHECK_NO); + if(invocationType==CONSTRUCTOR_INVOCATION&&rfs->baseClass!=rfs->currClass){ + // constructors are not inherited + rr = RETURN_NOT_FOUND; +@@ -2329,7 +2329,7 @@ S_extRecFindStr *javaCrErfsForMethodInvocationT(S_typeModifiers *tt, + erfs->params = NULL; + javaLoadClassSymbolsFromFile(tt->u.t); + rr = findStrRecordSym(iniFind(tt->u.t,&erfs->s), name->name, &erfs->memb, +- CLASS_TO_METHOD, ACC_CHECK_NO,VISIB_CHECK_NO); ++ SEARCH_IN_MEMBERS_NO,CLASS_TO_METHOD,ACC_CHECK_NO,VISIB_CHECK_NO); + if (rr != RETURN_OK) { + noSuchRecordError(name->name); + return(NULL); +@@ -2368,7 +2368,7 @@ S_extRecFindStr *javaCrErfsForMethodInvocationS(S_idIdent *super, + } + */ + rr = findStrRecordSym(iniFind(ss, &erfs->s), name->name, &erfs->memb, +- CLASS_TO_METHOD,ACC_CHECK_NO,VISIB_CHECK_NO); ++ SEARCH_IN_MEMBERS_NO,CLASS_TO_METHOD,ACC_CHECK_NO,VISIB_CHECK_NO); + if (rr != RETURN_OK) return(NULL); + return(erfs); + } +@@ -2400,7 +2400,7 @@ S_extRecFindStr *javaCrErfsForConstructorInvocation(S_symbol *clas, + erfs->params = NULL; + assert(clas->b.javaFileLoaded); + rr = findStrRecordSym(iniFind(clas, &erfs->s), clas->name, &erfs->memb, +- CLASS_TO_METHOD,ACC_CHECK_NO,VISIB_CHECK_NO); ++ SEARCH_IN_MEMBERS_NO,CLASS_TO_METHOD,ACC_CHECK_NO,VISIB_CHECK_NO); + if (rr != RETURN_OK) return(NULL); + return(erfs); + } +@@ -2733,7 +2733,7 @@ void javaInitArrayObject() { + + S_typeModifiers *javaArrayFieldAccess(S_idIdent *id) { + S_symbol *rec=NULL; +- findStrRecordFromType(&s_javaArrayObjectSymbol.u.s->stype, id, &rec, CLASS_TO_EXPR); ++ findStrRecordFromType(&s_javaArrayObjectSymbol.u.s->stype, id, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_EXPR); + assert(rec); + return(rec->u.type); + } +diff --git a/src/proto.h b/src/proto.h +index de83530..6521fa1 100644 +--- a/src/proto.h ++++ b/src/proto.h +@@ -27,6 +27,8 @@ enum miscellaneous { /* misc. constants */ + ACC_CHECK_NO, + VISIB_CHECK_YES, + VISIB_CHECK_NO, ++ SEARCH_IN_MEMBERS_YES, ++ SEARCH_IN_MEMBERS_NO, + CUT_OVERRIDEN_YES, + CUT_OVERRIDEN_NO, + CX_FILE_ITEM_GEN, +@@ -2274,6 +2276,7 @@ int javaGetMinimalAccessibility C_ARG((S_recFindStr *rfs, S_symbol *r)); + int findStrRecordSym C_ARG(( S_recFindStr *ss, + char *recname, + S_symbol **res, ++ int searchInMembers, + int javaClassif, + int accessCheck, + int visibilityCheck +@@ -2307,12 +2310,14 @@ int findStrRecord C_ARG(( S_symbol *s, + S_reference * findStrRecordFromSymbol C_ARG(( S_symbol *str, + S_idIdent *record, + S_symbol **res, ++ int searchInMembers, + int javaClassif, + S_idIdent *super + )); + S_reference * findStrRecordFromType C_ARG(( S_typeModifiers *str, + S_idIdent *record, + S_symbol **res, ++ int searchInMembers, + int javaClassif + )); + int mergeArguments C_ARG((S_symbol *id, S_symbol *ty)); +diff --git a/src/semact.c b/src/semact.c +index 9b3bc09..676981c 100644 +--- a/src/semact.c ++++ b/src/semact.c +@@ -268,11 +268,12 @@ int javaGetMinimalAccessibility(S_recFindStr *rfs, S_symbol *r) { + } + + int findStrRecordSym( S_recFindStr *ss, +- char *recname, /* can be NULL */ +- S_symbol **res, +- int javaClassif, /* classify to method/field*/ +- int accCheck, /* java check accessibility */ +- int visibilityCheck /* redundant, always equal to accCheck? */ ++ char *recname, /* can be NULL */ ++ S_symbol **res, ++ int searchInMembers, /* search im member structs/unions */ ++ int javaClassif, /* classify to method/field*/ ++ int accCheck, /* java check accessibility */ ++ int visibilityCheck /* redundant, always equal to accCheck? */ + ) { + S_symbol *s,*r,*cclass; + S_symbolList *sss; +@@ -334,6 +335,16 @@ int findStrRecordSym( S_recFindStr *ss, + } + FSRS_RETURN_WITH_SUCCESS(ss, res, r); + } ++ if (searchInMembers == SEARCH_IN_MEMBERS_YES ++ && r->name!=NULL && r->b.symType==TypeDefault) { ++ S_typeModifiers *type = r->u.type; ++ if (type->m == TypeArray) type = type->next; ++ if (type->m==TypeUnion || type->m==TypeStruct) { ++ if (ss->aui+1 < MAX_ANONYMOUS_FIELDS) { ++ ss->au[ss->aui++] = type->u.t; ++ } ++ } ++ } + nextRecord:; + } + nextClass: +@@ -366,15 +377,16 @@ int findStrRecord( S_symbol *s, + int javaClassif + ) { + S_recFindStr rfs; +- return(findStrRecordSym(iniFind(s,&rfs),recname,res,javaClassif, +- ACC_CHECK_YES,VISIB_CHECK_YES)); ++ return(findStrRecordSym(iniFind(s,&rfs),recname,res,SEARCH_IN_MEMBERS_NO, ++ javaClassif,ACC_CHECK_YES,VISIB_CHECK_YES)); + } + + /* and push reference */ + // this should be split into two copies, different for C and Java. + S_reference *findStrRecordFromSymbol( S_symbol *sym, + S_idIdent *record, +- S_symbol **res, ++ S_symbol **res, ++ int searchInMembers, + int javaClassif, + S_idIdent *super /* covering special case when invoked + as SUPER.sym, berk */ +@@ -386,7 +398,7 @@ S_reference *findStrRecordFromSymbol( S_symbol *sym, + ref = NULL; + // when in java, then always in qualified name, so access and visibility checks + // are useless. +- rr = findStrRecordSym(iniFind(sym,&rfs),record->name,res, ++ rr = findStrRecordSym(iniFind(sym,&rfs),record->name,res,searchInMembers, + javaClassif, ACC_CHECK_NO, VISIB_CHECK_NO); + if (rr == RESULT_OK && rfs.currClass!=NULL && + ((*res)->b.storage==StorageField +@@ -415,6 +427,7 @@ S_reference *findStrRecordFromSymbol( S_symbol *sym, + S_reference * findStrRecordFromType( S_typeModifiers *str, + S_idIdent *record, + S_symbol **res, ++ int searchInMembers, + int javaClassif + ) { + S_reference *ref; +@@ -425,7 +438,7 @@ S_reference * findStrRecordFromType( S_typeModifiers *str, + *res = &s_errorSymbol; + goto fini; + } +- ref = findStrRecordFromSymbol( str->u.t, record, res, javaClassif, NULL); ++ ref = findStrRecordFromSymbol( str->u.t, record, res, searchInMembers, javaClassif, NULL); + fini: + return(ref); + } +@@ -601,13 +614,11 @@ void addInitializerRefs( + tt = t; + rec = NULL; + for (id = &ll->idi; id!=NULL; id=id->next) { +- if (tt->m == TypeArray) { +- tt = tt->next; +- continue; +- } +- if (tt->m != TypeStruct && tt->m != TypeUnion) return; +- ref = findStrRecordFromType(tt, id, &rec, CLASS_TO_ANY); +- if (NULL == ref) return; ++ if (id->name == NULL) continue; ++ if (tt->m == TypeArray) tt = tt->next; ++ if (tt->m != TypeStruct && tt->m != TypeUnion) break; ++ ref = findStrRecordFromType(tt, id, &rec, SEARCH_IN_MEMBERS_YES, CLASS_TO_ANY); ++ if (NULL == ref) break; + assert(rec); + tt = rec->u.type; + } +diff --git a/src/yaccgram.y b/src/yaccgram.y +index d5f0da6..ed2fde7 100644 +--- a/src/yaccgram.y ++++ b/src/yaccgram.y +@@ -608,7 +608,7 @@ postfix_expr + } + | postfix_expr {SetStrCompl1($1.d.t);} '.' str_rec_identifier { + S_symbol *rec=NULL; +- $$.d.r = findStrRecordFromType($1.d.t, $4.d, &rec, CLASS_TO_ANY); ++ $$.d.r = findStrRecordFromType($1.d.t, $4.d, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_ANY); + assert(rec); + $$.d.t = rec->u.type; + assert($$.d.t); +@@ -618,7 +618,7 @@ postfix_expr + S_symbol *rec=NULL; + $$.d.r = NULL; + if ($1.d.t->m==TypePointer || $1.d.t->m==TypeArray) { +- $$.d.r = findStrRecordFromType($1.d.t->next, $4.d, &rec, CLASS_TO_ANY); ++ $$.d.r = findStrRecordFromType($1.d.t->next, $4.d, &rec, SEARCH_IN_MEMBERS_NO, CLASS_TO_ANY); + assert(rec); + $$.d.t = rec->u.type; + } else $$.d.t = &s_errorModifier; +@@ -1639,11 +1639,11 @@ initializer0 + } + | designator_list '=' initializer { + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); ++ FILL_idIdentList($$.d, *$1.d, NULL, TypeDefault, $3.d,NULL); + } + | str_rec_identifier ':' initializer { /* GNU-extension*/ + $$.d = StackMemAlloc(S_idIdentList); +- FILL_idIdentList($$.d, *$1.d, $1.d->name, TypeDefault, $3.d,NULL); ++ FILL_idIdentList($$.d, *$1.d, NULL, TypeDefault, $3.d,NULL); + } + ; + +@@ -1660,11 +1660,11 @@ designator_list + designator + : '[' constant_expr ']' { + $$.d = StackMemAlloc(S_idIdent); +- FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ FILL_idIdent($$.d, NULL, NULL, s_noPos, NULL); + } + | '[' constant_expr ELIPSIS constant_expr ']' { + $$.d = StackMemAlloc(S_idIdent); +- FILL_idIdent($$.d, "", NULL, s_noPos, NULL); ++ FILL_idIdent($$.d, NULL, NULL, s_noPos, NULL); + } + | '.' str_rec_identifier { + $$.d = StackMemAlloc(S_idIdent); +-- +2.18.0 + diff --git a/0033-Fix-Elisp-obsolete-functions.patch b/0033-Fix-Elisp-obsolete-functions.patch new file mode 100644 index 000000000000..1c6d631ef167 --- /dev/null +++ b/0033-Fix-Elisp-obsolete-functions.patch @@ -0,0 +1,245 @@ +From 609affa722a34959eebae4cebabbaa6853621044 Mon Sep 17 00:00:00 2001 +From: Sergei Litvin <litvindev@gmail.com> +Date: Sat, 30 Jun 2018 18:15:28 +0300 +Subject: [PATCH 33/33] Fix Elisp obsolete functions + +--- + env/emacs/xref.el | 56 ++++++++++++++++++++++----------------------- + 1 file changed, 28 insertions(+), 28 deletions(-) + +diff --git a/env/emacs/xref.el b/env/emacs/xref.el +index 1215007..f31523b 100644 +--- a/env/emacs/xref.el ++++ b/env/emacs/xref.el +@@ -1782,7 +1782,7 @@ tries to delete xrefactory windows first. + (forward-char 1) + (search-forward-regexp "[^0-9]" (point-max) 0) + (setq ne (point)) +- (setq line (string-to-int (buffer-substring e (- ne 1)))) ++ (setq line (string-to-number (buffer-substring e (- ne 1)))) + ) + ) + (goto-char p) +@@ -2410,7 +2410,7 @@ tries to delete xrefactory windows first. + ) + (setq i (+ i 1)) + ) +- (setq pn (string-to-int (substring ss j i))) ++ (setq pn (string-to-number (substring ss j i))) + (message "progress %s%%" pn) + (setq i (xref-server-dispatch-skip-blank ss i len)) + )) +@@ -2685,7 +2685,7 @@ tries to delete xrefactory windows first. + (setq opts (append (list "-refactory" + "-xrefrc" xref-options-file + "-p" xref-active-project +- "-user" (int-to-string frame-id) ++ "-user" (number-to-string frame-id) + ) + opts)) + (setq enc (xref-encoding-option)) +@@ -2721,7 +2721,7 @@ tries to delete xrefactory windows first. + (setq opts (append opts (list "-errors" + "-xrefrc" xref-options-file + "-p" xref-active-project +- "-user" (int-to-string (xref-get-this-frame-id)) ++ "-user" (number-to-string (xref-get-this-frame-id)) + ))) + (setq enc (xref-encoding-option)) + (if (not (equal enc "")) +@@ -2925,7 +2925,7 @@ on active project selection). + (setq res 0) + (setq as (assoc attr xref-server-ctag-attributes)) + (if as +- (setq res (string-to-int (cdr as))) ++ (setq res (string-to-number (cdr as))) + ) + res + )) +@@ -3027,8 +3027,8 @@ on active project selection). + (xref-server-dispatch-require-end-ctag tag) + (xref-select-dispach-data-caller-window dispatch-data) + (xref-display-and-set-new-dialog-window xref-error-modal-buffer nil t) +- (insert-string "[error] : ") +- (insert-string cc) ++ (insert "[error] : ") ++ (insert cc) + (goto-char (point-min)) + (xref-appropriate-window-height nil t) + (beep t) +@@ -3053,8 +3053,8 @@ on active project selection). + () ;; do nothing if debug information and mode is off + (xref-select-dispach-data-caller-window dispatch-data) + (setq dw (xref-display-and-set-new-dialog-window xref-info-modal-buffer nil t)) +- ;;(insert-string "[info] : ") +- (insert-string cc) ++ ;;(insert "[info] : ") ++ (insert cc) + (goto-char (point-min)) + (xref-appropriate-window-height nil t) + (xref-read-key-sequence "Press a key to continue") +@@ -3326,7 +3326,7 @@ No. + "-olcxtrivialprecheck -getlastimportline" + dispatch-data) + (setq iline (cdr (assoc 'info dispatch-data))) +- (setq iline-val (string-to-int iline)) ++ (setq iline-val (string-to-number iline)) + (save-excursion + (goto-line (+ iline-val 1)) + (beginning-of-line) +@@ -3522,7 +3522,7 @@ Special hotkeys available: + (setq tlen (xref-server-dispatch-get-int-attr PPCA_LEN)) + (setq cc (xref-char-list-substring ss i (+ i tlen))) + (setq i (+ i tlen)) +- (insert-string cc) ++ (insert cc) + (newline) + (setq i (xref-server-parse-xml-tag ss i len)) + (xref-server-dispatch-require-end-ctag PPC_MULTIPLE_COMPLETION_LINE) +@@ -3546,7 +3546,7 @@ Special hotkeys available: + (setq tlen (xref-server-dispatch-get-int-attr PPCA_LEN)) + (setq cc (xref-char-list-substring ss i (+ i tlen))) + (setq i (+ i tlen)) +- (insert-string cc) ++ (insert cc) + (setq i (xref-server-parse-xml-tag ss i len)) + (xref-server-dispatch-require-end-ctag PPC_ALL_COMPLETIONS) + (xref-line-hightlight 0 (point-max) nil 1 xref-font-lock-compl-keywords t) +@@ -3649,7 +3649,7 @@ Special hotkeys available: + )) + + (defun xref-server-dispatch-refactoring-paste-block (ss i len dispatch-data) +- (insert-string xref-refactoring-block) ++ (insert xref-refactoring-block) + (setq i (xref-server-parse-xml-tag ss i len)) + (xref-server-dispatch-require-end-ctag PPC_REFACTORING_PASTE_BLOCK) + i +@@ -3864,8 +3864,8 @@ Special hotkeys available: + (setq winconfig (current-window-configuration)) + (delete-other-windows) + (setq messagewin (xref-display-and-set-new-dialog-window xref-browser-info-buffer nil t)) +- (insert-string mess) +- (insert-string xref-resolution-dialog-explication) ++ (insert mess) ++ (insert xref-resolution-dialog-explication) + (goto-char (point-min)) + (xref-create-browser-windows t dispatch-data) + (xref-browser-dialog-set-new-filter dispatch-data) +@@ -4390,7 +4390,7 @@ Special hotkeys available: + (let ((key) (res) (win) (owin)) + (setq owin (selected-window)) + (setq win (xref-display-and-set-new-dialog-window title nil t)) +- (insert-string text) ++ (insert text) + (xref-use-local-map keymap) + (goto-line line) + (xref-appropriate-window-height nil t) +@@ -5189,7 +5189,7 @@ belonging to this project. + "Do you compile sources several times with different macro settings [yn]? " "n")) + (if (or (equal aaa "y") (equal aaa "Y")) + (progn +- (setq pasn (string-to-int ++ (setq pasn (string-to-number + (read-from-minibuffer + "How many compilations with different initial macro settings: " "2"))) + (setq aaa (read-from-minibuffer +@@ -5797,7 +5797,7 @@ is successful. See also `xref-ide-compile' and `xref-ide-run'. + (insert (substring cc (+ j tlen 4))) + (put-text-property bp (point) 'mouse-face 'highlight) + ) +- (insert-string cc) ++ (insert cc) + ) + i + )) +@@ -5810,7 +5810,7 @@ is successful. See also `xref-ide-compile' and `xref-ide-run'. + (setq i (+ i tlen)) + (setq i (xref-server-parse-xml-tag ss i len)) + (xref-server-dispatch-require-end-ctag tag) +- (insert-string cc) ++ (insert cc) + (newline) + i + )) +@@ -5883,7 +5883,7 @@ is successful. See also `xref-ide-compile' and `xref-ide-run'. + ) + (if (eq di 0) (setq di i)) + (setq file (substring line b di)) +- (setq ln (string-to-int (substring line (+ di 1) i))) ++ (setq ln (string-to-number (substring line (+ di 1) i))) + (xref-show-file-line-in-caller-window file ln) + ) + (xref-find-file-on-point) +@@ -6193,7 +6193,7 @@ file. + (forward-char i) + (xref-delete-pending-ident-after-completion) + (setq ccc (substring cc i)) +- (if (not (equal ccc "")) (insert-string ccc)) ++ (if (not (equal ccc "")) (insert ccc)) + )) + + (defun xref-insert-completion (completion) +@@ -7478,7 +7478,7 @@ symbol name (the identifier) is checked against the given string(s). + (defun xref-interactive-browser-dialog-set-filter (event) + (interactive "i") + (let ((level)) +- (setq level (string-to-int (char-to-string last-input-char))) ++ (setq level (string-to-number (char-to-string last-input-char))) + (xref-browser-or-refs-set-filter level) + )) + +@@ -8199,7 +8199,7 @@ files after each important refactoring. + (get-buffer-create xref-vc-log-buffer) + (set-buffer xref-vc-log-buffer) + (goto-char (point-max)) +- (insert-string (format "%s: %s" ++ (insert (format "%s: %s" + (current-time-string) + description)) + (newline) +@@ -8280,7 +8280,7 @@ files after each important refactoring. + "Insert parameter at position [ 1 - arity('%s') ] : " name) + "1" + )) +- (setq arg (string-to-int argns)) ++ (setq arg (string-to-number argns)) + (if (and rd (equal (car (cdr rd)) "macro")) + (setq default "ARG") + (setq default "int arg") +@@ -8312,7 +8312,7 @@ files after each important refactoring. + "Delete parameter from position [ 1 - arity('%s') ] : " name) + "1" + )) +- (setq arg (string-to-int argns)) ++ (setq arg (string-to-number argns)) + (xref-non-interactive-del-parameter name arg) + )) + +@@ -8335,13 +8335,13 @@ files after each important refactoring. + "Position of parameter to move [ 1 - arity('%s') ] : " name) + "1" + )) +- (setq arg1 (string-to-int argns)) ++ (setq arg1 (string-to-number argns)) + (setq argns (read-from-minibuffer + (format + "Move to position [ 1 - arity('%s') ] : " name) + "2" + )) +- (setq arg2 (string-to-int argns)) ++ (setq arg2 (string-to-number argns)) + (xref-non-interactive-move-parameter name arg1 arg2) + )) + +@@ -8546,7 +8546,7 @@ files after each important refactoring. + )) + (setq field (read-from-minibuffer + "Optionally the field getting method's object from the argument [\"\"] ")) +- (setq arg (string-to-int argns)) ++ (setq arg (string-to-number argns)) + (xref-refactoring-init-actions (format "making %s virtual" name)) + (xref-server-call-refactoring-task + (list +-- +2.18.0 + diff --git a/0034-Fix-Makefile.common.patch b/0034-Fix-Makefile.common.patch new file mode 100644 index 000000000000..d2197d7132ff --- /dev/null +++ b/0034-Fix-Makefile.common.patch @@ -0,0 +1,36 @@ +diff -u a/src/Makefile.common b/src/Makefile.common.new +--- a/src/Makefile.common ++++ b/src/Makefile.common.new +@@ -68,18 +68,18 @@ + mv y.tab.c cexp.c + + strFill.h: proto.h strTdef.h +- xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ ++ ./xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ + -str_fill -header \ + > tmpStrFill.h + mv -f tmpStrFill.h strFill.h + + strTdef.h: proto.h + echo > strTdef.h +- xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ ++ ./xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ + -typedefs -enum_name -header \ + > tmpStrTdef.h + mv -f tmpStrTdef.h strTdef.h +- xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ ++ ./xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ + -typedefs -enum_name -header \ + > tmpStrTdef.h + mv -f tmpStrTdef.h strTdef.h +@@ -87,7 +87,7 @@ + enumTxt.c: proto.h strFill.h strTdef.h ../doc/_xrefrc + echo "#include \"stdinc.h\"" > enumTxt.c + echo "#include \"proto.h\" /*SBD*/" >> enumTxt.c +- xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ ++ ./xref.bs -task_regime_generate $(COMCFLAGS) proto.h \ + -enum_name -body >> enumTxt.c + + ######################################################################### + +Diff finished. Sat Sep 15 02:01:11 2018 diff --git a/0035-Fix-clash-with-library-names.patch b/0035-Fix-clash-with-library-names.patch new file mode 100644 index 000000000000..15d876228e02 --- /dev/null +++ b/0035-Fix-clash-with-library-names.patch @@ -0,0 +1,154 @@ +diff -u a/env/emacs/xref.el b/env/emacs/xref.el +--- a/env/emacs/xref.el ++++ b/env/emacs/xref.el +@@ -29,7 +29,7 @@ + ;; profit from Xrefactory's project management. Of course, we also + ;; acknowledge the developers and maintainers of GNU Emacs and XEmacs. + +-(provide 'xref) ++(provide 'xrefactory2) + + (load "xrefprotocol") + +diff -u a/env/emacs/xrefactory.el b/env/emacs/xrefactory.el +--- a/env/emacs/xrefactory.el ++++ b/env/emacs/xrefactory.el +@@ -1127,72 +1127,72 @@ + (defvar xref-default-documentation-string "Documentation not yet available, please invoke an Xrefactory function first.") + + +-(autoload 'xref-global-options "xref" xref-default-documentation-string t) +-(autoload 'xref-project-new "xref" xref-default-documentation-string t) +-(autoload 'xref-project-delete "xref" xref-default-documentation-string t) +-(autoload 'xref-project-set-active "xref" xref-default-documentation-string t) +-(autoload 'xref-project-active "xref" xref-default-documentation-string t) +-(autoload 'xref-project-edit-options "xref" xref-default-documentation-string t) +- +-(autoload 'xref-ide-compile-file "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-compile-dir "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-compile-project "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-compile "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-previous-error "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-run "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-run-this "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-run1 "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-run2 "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-run3 "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-run4 "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-run5 "xref" xref-default-documentation-string t) +-(autoload 'xref-ide-compile-run "xref" xref-default-documentation-string t) +- +-(autoload 'xref-create-refs "xref" xref-default-documentation-string t) +-(autoload 'xref-fast-update-refs "xref" xref-default-documentation-string t) +-(autoload 'xref-update-refs "xref" xref-default-documentation-string t) +-(autoload 'xref-gen-html-documentation "xref" xref-default-documentation-string t) +- +-(autoload 'xref-alternative-previous-reference "xref" xref-default-documentation-string t) +-(autoload 'xref-alternative-next-reference "xref" xref-default-documentation-string t) +- +-(autoload 'xref-push-references "xref" xref-default-documentation-string t) +-(autoload 'xref-push-and-goto-definition "xref" xref-default-documentation-string t) +-(autoload 'xref-browse-symbol "xref" xref-default-documentation-string t) +-(autoload 'xref-push-name "xref" xref-default-documentation-string t) +-(autoload 'xref-push-and-apply-macro "xref" xref-default-documentation-string t) +-(autoload 'xref-next-reference "xref" xref-default-documentation-string t) +-(autoload 'xref-previous-reference "xref" xref-default-documentation-string t) +-(autoload 'xref-pop-and-return "xref" xref-default-documentation-string t) +-(autoload 'xref-pop-only "xref" xref-default-documentation-string t) +-(autoload 'xref-show-browser "xref" xref-default-documentation-string t) +-(autoload 'xref-re-push "xref" xref-default-documentation-string t) +- +-(autoload 'xref-search-in-tag-file "xref" xref-default-documentation-string t) +-(autoload 'xref-search-definition-in-tag-file "xref" xref-default-documentation-string t) +- +-(autoload 'xref-push-this-file-unused-symbols "xref" xref-default-documentation-string t) +-(autoload 'xref-push-global-unused-symbols "xref" xref-default-documentation-string t) +- +-(autoload 'xref-delete-window "xref" xref-default-documentation-string t) +- +-(autoload 'xref-set-moving-target-position "xref" xref-default-documentation-string t) +-(autoload 'xref-refactor "xref" xref-default-documentation-string t) +-(autoload 'xref-undo-last-refactoring "xref" xref-default-documentation-string t) +- +-(autoload 'xref-completion "xref" xref-default-documentation-string t) +- +-(autoload 'xref-class-tree-show "xref" xref-default-documentation-string t) +- +-(autoload 'xref-help "xref" xref-default-documentation-string t) +-(autoload 'xref-about "xref" xref-default-documentation-string t) +-(autoload 'xref-kill-xref-process "xref" xref-default-documentation-string t) +-(autoload 'xref-registration "xref" xref-default-documentation-string t) ++(autoload 'xref-global-options "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-project-new "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-project-delete "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-project-set-active "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-project-active "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-project-edit-options "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-ide-compile-file "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-compile-dir "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-compile-project "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-compile "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-previous-error "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-run "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-run-this "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-run1 "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-run2 "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-run3 "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-run4 "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-run5 "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-ide-compile-run "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-create-refs "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-fast-update-refs "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-update-refs "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-gen-html-documentation "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-alternative-previous-reference "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-alternative-next-reference "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-push-references "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-push-and-goto-definition "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-browse-symbol "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-push-name "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-push-and-apply-macro "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-next-reference "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-previous-reference "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-pop-and-return "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-pop-only "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-show-browser "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-re-push "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-search-in-tag-file "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-search-definition-in-tag-file "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-push-this-file-unused-symbols "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-push-global-unused-symbols "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-delete-window "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-set-moving-target-position "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-refactor "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-undo-last-refactoring "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-completion "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-class-tree-show "xrefactory2" xref-default-documentation-string t) ++ ++(autoload 'xref-help "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-about "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-kill-xref-process "xrefactory2" xref-default-documentation-string t) ++(autoload 'xref-registration "xrefactory2" xref-default-documentation-string t) + +-(autoload 'xref-find-file-on-mouse "xref" xref-default-documentation-string t) ++(autoload 'xref-find-file-on-mouse "xrefactory2" xref-default-documentation-string t) + + ;; this has to be kept, because of options +-(autoload 'xref-soft-select-dispach-data-caller-window "xref" xref-default-documentation-string t) ++(autoload 'xref-soft-select-dispach-data-caller-window "xrefactory2" xref-default-documentation-string t) + + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +diff --git a/env/emacs/xref.el b/env/emacs/xrefactory2.el +rename from env/emacs/xref.el +rename to env/emacs/xrefactory2.el diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..4ba1b5707cae --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,156 @@ +# Maintainer: Sergei Litvin <litvindev@gmail.com> + +pkgname=xrefactory +pkgdesc="Professional refactoring tool for C/Java and Emacs" +url="http://xrefactory.com" +pkgver=1.6.10 +pkgrel=1 +arch=('x86_64') +license=(custom) +depends=('glibc' 'gcc') +source=( + http://xrefactory.com/xrefactory/downloads/$pkgver/$pkgname-$pkgver-src.tgz + 0001-Fix-wrong-use-of-memset.patch + 0006-Fix-restoring-regs-after-longjmp.patch + 0007-Fix-mbMemory-cfMemory-tmpWorkMemory-overflowed.patch + 0008-The-variable-xref-set-this-frame-dispatch-data.patch + 0009-Parse-pragma-once-directive.patch + 0010-Parse-include_next-directive.patch + 0011-Detect-GCC-include-directories.patch + 0012-Detect-GCC-Predefined-Macros.patch + 0013-Make-exactpositionresolve-option-affecting-symbols.patch + 0014-Make-include-file-option-processing-file-as-input.patch + 0015-Parse-initializer-list-for-arrays-structs-unions.patch + 0016-Parse-empty-fields-in-struct-declarations.patch + 0017-Parse-asm-statement.patch + 0018-Parse-ranges-in-case-labeled-statement.patch + 0019-Add-missed-C-keywords.patch + 0020-Add-GCC-keyword-extensions.patch + 0021-Add-GCC-built-in-functions.patch + 0022-Fix-macro-expansion-for-constant-parameters.patch + 0023-Fix-__VA_ARGS__-expansion-in-macro-if-variable-argum.patch + 0024-Allow-to-process-.y-files-and-refine-C-grammar-in-ya.patch + 0025-Parse-typeof-keyword.patch + 0026-Add-showincludes-option.patch + 0027-Fix-if-defined-XXX-usage-references.patch + 0028-Check-previous-link-names-for-enums-structs-unions.patch + 0029-Parse-obsolete-GCC-structs-unions-initializer-list.patch + 0030-Fix-stdop-and-optinclude-options.patch + 0031-Fix-parsing-arrays-structs-unions-initializer-list.patch + 0033-Fix-Elisp-obsolete-functions.patch + 0034-Fix-Makefile.common.patch + 0035-Fix-clash-with-library-names.patch) +md5sums=('63e10baa9a5dfce9165570e7c3897701' + '4791f8a42e53a141ded3bd36e39b3a6d' + 'a00b17df920380afd6689369845acbc8' + '12b0691bade1c2cf54f7d65be627e4ed' + 'd03d650d3379b9803e9c6e33d00bff01' + '4016cb112001986916c4f8339cf15558' + 'c396819441e5eefcf853c6fd95e8b235' + 'd3d4a5c0b2f092a7870a3f07cf1e7ed4' + 'eadbf7b35f36fbb714411852e0be7526' + '0dbaae243f9406b086b06e74976dee56' + '8cec60b31a4caf9a1593073d690a66bf' + '5d57e22fb4559632db54da28f98b55ff' + '727c48c11af8d7b21ce32272ab17aa39' + '04af9e30863641db22cdc1f25ec35730' + '2a4dd004387c50787be3adb4412f2865' + 'e841cbbbafa06012db6edbe1fbc26936' + '302bec1cc494984d108da0a392be30c8' + '387e847d3e19d64f8883d649ba31e54b' + '081d03063e8f34223c7fa74982cc240e' + '4a1b6647233483e20fe861425e331d76' + '4a2e62ff6a6d3c3afe4318fd90f939b5' + '4245381509065daa86941467e5ad102c' + '2c4132f8c6f22352af7390678f4d4304' + '1684460f5a1d16907428c868d75a27b4' + '59cf224ed498b053ea3f84a2033d7f66' + '5c758605b952d406b17f596afe87eeb5' + '86c7bf7215f680e2b0d50db80ae908d6' + '501a1993fbb4e0ac88351c10a678866d' + '8549dc467458994dda13c8fdeef7dee6' + '633789164b37a833579fb23b1b16c5f1' + 'ff4ac43651958f8e5f61f19858a87aa7') + +prepare() { + cd "$srcdir/xref-any" + patch --verbose -p1 -i "$srcdir/0001-Fix-wrong-use-of-memset.patch" + patch --verbose -p1 -i "$srcdir/0006-Fix-restoring-regs-after-longjmp.patch" + patch --verbose -p1 -i "$srcdir/0007-Fix-mbMemory-cfMemory-tmpWorkMemory-overflowed.patch" + patch --verbose -p1 -i "$srcdir/0008-The-variable-xref-set-this-frame-dispatch-data.patch" + patch --verbose -p1 -i "$srcdir/0009-Parse-pragma-once-directive.patch" + patch --verbose -p1 -i "$srcdir/0010-Parse-include_next-directive.patch" + patch --verbose -p1 -i "$srcdir/0011-Detect-GCC-include-directories.patch" + patch --verbose -p1 -i "$srcdir/0012-Detect-GCC-Predefined-Macros.patch" + patch --verbose -p1 -i "$srcdir/0013-Make-exactpositionresolve-option-affecting-symbols.patch" + patch --verbose -p1 -i "$srcdir/0014-Make-include-file-option-processing-file-as-input.patch" + patch --verbose -p1 -i "$srcdir/0015-Parse-initializer-list-for-arrays-structs-unions.patch" + patch --verbose -p1 -i "$srcdir/0016-Parse-empty-fields-in-struct-declarations.patch" + patch --verbose -p1 -i "$srcdir/0017-Parse-asm-statement.patch" + patch --verbose -p1 -i "$srcdir/0018-Parse-ranges-in-case-labeled-statement.patch" + patch --verbose -p1 -i "$srcdir/0019-Add-missed-C-keywords.patch" + patch --verbose -p1 -i "$srcdir/0020-Add-GCC-keyword-extensions.patch" + patch --verbose -p1 -i "$srcdir/0021-Add-GCC-built-in-functions.patch" + patch --verbose -p1 -i "$srcdir/0022-Fix-macro-expansion-for-constant-parameters.patch" + patch --verbose -p1 -i "$srcdir/0023-Fix-__VA_ARGS__-expansion-in-macro-if-variable-argum.patch" + patch --verbose -p1 -i "$srcdir/0024-Allow-to-process-.y-files-and-refine-C-grammar-in-ya.patch" + patch --verbose -p1 -i "$srcdir/0025-Parse-typeof-keyword.patch" + patch --verbose -p1 -i "$srcdir/0026-Add-showincludes-option.patch" + patch --verbose -p1 -i "$srcdir/0027-Fix-if-defined-XXX-usage-references.patch" + patch --verbose -p1 -i "$srcdir/0028-Check-previous-link-names-for-enums-structs-unions.patch" + patch --verbose -p1 -i "$srcdir/0029-Parse-obsolete-GCC-structs-unions-initializer-list.patch" + patch --verbose -p1 -i "$srcdir/0030-Fix-stdop-and-optinclude-options.patch" + patch --verbose -p1 -i "$srcdir/0031-Fix-parsing-arrays-structs-unions-initializer-list.patch" + patch --verbose -p1 -i "$srcdir/0033-Fix-Elisp-obsolete-functions.patch" + patch --verbose -p1 -i "$srcdir/0034-Fix-Makefile.common.patch" + patch --verbose -p1 -i "$srcdir/0035-Fix-clash-with-library-names.patch" + cd "$srcdir/xref-any/doc" + cat "INSTALL" "readme" "readme2" > README +} + +build() { + cd "$srcdir/xref-any/src" + make +} + +package() { + mkdir -p "$pkgdir/usr/bin" \ + "$pkgdir/usr/share/man" \ + "$pkgdir/usr/share/man/man1" \ + "$pkgdir/usr/share/man/man5" \ + "$pkgdir/usr/share/emacs" \ + "$pkgdir/usr/share/emacs/site-lisp" \ + "$pkgdir/usr/share/xrefactory" \ + "$pkgdir/usr/share/xrefactory/cexercise" \ + "$pkgdir/usr/share/xrefactory/cexercise/refactorings" \ + "$pkgdir/usr/share/xrefactory/jexercise" \ + "$pkgdir/usr/share/xrefactory/jexercise/com" \ + "$pkgdir/usr/share/xrefactory/jexercise/com/xrefactory" \ + "$pkgdir/usr/share/xrefactory/jexercise/com/xrefactory/refactorings" \ + "$pkgdir/usr/share/licenses/xrefactory" + cd "$srcdir/xref-any/src" + install -m 755 "xref" "$pkgdir/usr/bin" + cd "$srcdir/xref-any/doc" + install -m 644 "xref.man" "$pkgdir/usr/share/man/man1/xref.1" + install -m 644 "xrefrc.man" "$pkgdir/usr/share/man/man5/xrefrc.5" + install -m 644 "README" "$pkgdir/usr/share/xrefactory" + install -m 644 "LICENSE" "$pkgdir/usr/share/licenses/xrefactory" + cd "$srcdir/xref-any/doc/cexercise" + install -m 644 "browsing.c" "completions.c" "ideCompileAndRun.c" "index.c" \ + "$pkgdir/usr/share/xrefactory/cexercise" + cd "$srcdir/xref-any/doc/cexercise/refactorings" + install -m 644 "extract.c" "index.c" "parameter.c" "rename.c" \ + "$pkgdir/usr/share/xrefactory/cexercise/refactorings" + cd "$srcdir/xref-any/doc/jexercise" + install -m 644 "Index.java" "$pkgdir/usr/share/xrefactory/jexercise" + cd "$srcdir/xref-any/doc/jexercise/com/xrefactory" + install -m 644 "Browsing.java" "Completion.java" "IdeCompileRun.java" \ + "$pkgdir/usr/share/xrefactory/jexercise/com/xrefactory" + cd "$srcdir/xref-any/doc/jexercise/com/xrefactory/refactorings" + install -m 644 "AddRemoveParameter.java" "EncapsulateField.java" "Index.java" "MoveStaticMethod.java" \ + "RenameSymbol.java" "ExtractMethod.java" "MoveMethod.java" "PullUpMethod.java" \ + "$pkgdir/usr/share/xrefactory/jexercise/com/xrefactory/refactorings" + cd "$srcdir/xref-any/env/emacs" + install -m 644 "xrefactory.el" "xrefactory2.el" "xrefdoc.el" "xrefprotocol.el" \ + "$pkgdir/usr/share/emacs/site-lisp" +} |