wangziqi2013/CFront

Failed to compile project!

Closed this issue · 1 comments

There are dozens of different errors in the code. I tried to solve them one by one, but there are really many of them. Here are some of them:

[max@workstation src]$ make
gcc test_lex.o stack.o token.o error.o ast.o hashtable.o -o ./bin/test_lex -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
gcc ./test/test_parse.c -c -o /home/max/Projects/Git/CFront/src/test_parse.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
gcc parse_exp.c -c -o parse_exp.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc parse_decl.c -c -o parse_decl.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
parse_decl.c: In function ‘parse_typespec’:
parse_decl.c:59:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
   59 |     case T_SIGNED: token_free(token_get_next(cxt->token_cxt)); // Fall through again
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse_decl.c:60:5: note: here
   60 |     case T_CHAR: case T_SHORT: case T_INT: case T_LONG: {      // Note: Do not get_next_token() on these types
      |     ^~~~
cc1: all warnings being treated as errors
make: *** [Makefile:68: parse_decl.o] Error 1
[max@workstation src]$ make
gcc parse_decl.c -c -o parse_decl.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
parse_decl.c: In function ‘parse_typespec’:
parse_decl.c:59:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
   59 |     case T_SIGNED: token_free(token_get_next(cxt->token_cxt)); // Fall through again
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse_decl.c:60:5: note: here
   60 |     case T_CHAR: case T_SHORT: case T_INT: case T_LONG: {      // Note: Do not get_next_token() on these types
      |     ^~~~
cc1: all warnings being treated as errors
make: *** [Makefile:68: parse_decl.o] Error 1
[max@workstation src]$ make
gcc parse_decl.c -c -o parse_decl.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
parse_decl.c: In function ‘parse_typespec’:
parse_decl.c:59:5: error: ‘breka’ undeclared (first use in this function)
   59 |     breka;
      |     ^~~~~
parse_decl.c:59:5: note: each undeclared identifier is reported only once for each function it appears in
parse_decl.c:58:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
   58 |     case T_UNSIGNED: usign = 1;                                // Fall through
      |                      ~~~~~~^~~
parse_decl.c:60:5: note: here
   60 |     case T_SIGNED: token_free(token_get_next(cxt->token_cxt)); // Fall through again
      |     ^~~~
cc1: all warnings being treated as errors
make: *** [Makefile:68: parse_decl.o] Error 1
[max@workstation src]$ make
gcc parse_decl.c -c -o parse_decl.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
parse_decl.c: In function ‘parse_typespec’:
parse_decl.c:59:5: error: ‘breka’ undeclared (first use in this function)
   59 |     breka;
      |     ^~~~~
parse_decl.c:59:5: note: each undeclared identifier is reported only once for each function it appears in
parse_decl.c:58:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
   58 |     case T_UNSIGNED: usign = 1;                                // Fall through
      |                      ~~~~~~^~~
parse_decl.c:60:5: note: here
   60 |     case T_SIGNED: token_free(token_get_next(cxt->token_cxt)); // Fall through again
      |     ^~~~
cc1: all warnings being treated as errors
make: *** [Makefile:68: parse_decl.o] Error 1
[max@workstation src]$ 
[max@workstation src]$ make
gcc parse_decl.c -c -o parse_decl.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc parse_comp.c -c -o parse_comp.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc parse_stmt.c -c -o parse_stmt.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc parse.c -c -o parse.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc eval.c -c -o eval.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc type.c -c -o type.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
type.c: In function ‘type_int_promo’:
type.c:964:7: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
  964 |       if(need_copy) type = type_init_from(cxt, type, type->offset); break;
      |       ^~
type.c:964:69: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  964 |       if(need_copy) type = type_init_from(cxt, type, type->offset); break;
      |                                                                     ^~~~~
type.c: In function ‘type_typeof’:
type.c:1104:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1104 |       lhs = lhs->next;
      |       ~~~~^~~~~~~~~~~
type.c:1106:5: note: here
 1106 |     case EXP_DOT: {
      |     ^~~~
cc1: all warnings being treated as errors
make: *** [Makefile:104: type.o] Error 1
[max@workstation src]$ make
gcc type.c -c -o type.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
type.c: In function ‘type_int_promo’:
type.c:964:7: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
  964 |       if(need_copy) type = type_init_from(cxt, type, type->offset); break;
      |       ^~
type.c:964:69: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  964 |       if(need_copy) type = type_init_from(cxt, type, type->offset); break;
      |                                                                     ^~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:104: type.o] Error 1
[max@workstation src]$ make
gcc type.c -c -o type.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc list.c -c -o list.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc bintree.c -c -o bintree.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc str.c -c -o str.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: type.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc eval.c -c -o eval.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc type.c -c -o type.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.c:7: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1
[max@workstation src]$ make
gcc eval.c -c -o eval.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
eval.c: In function ‘eval_const_get_mask’:
eval.c:17:22: error: ‘eval_int_masks’ undeclared (first use in this function)
   17 |   uint64_t op_mask = eval_int_masks[size];
      |                      ^~~~~~~~~~~~~~
eval.c:17:22: note: each undeclared identifier is reported only once for each function it appears in
eval.c: In function ‘eval_const_get_sign_mask’:
eval.c:23:24: error: ‘eval_int_masks’ undeclared (first use in this function)
   23 |   uint64_t sign_mask = eval_int_masks[size];
      |                        ^~~~~~~~~~~~~~
eval.c:22:39: error: parameter ‘size’ set but not used [-Werror=unused-but-set-parameter]
   22 | uint64_t eval_const_get_sign_mask(int size) {
      |                                   ~~~~^~~~
cc1: all warnings being treated as errors
make: *** [Makefile:107: eval.o] Error 1
[max@workstation src]$ make
gcc eval.c -c -o eval.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc type.c -c -o type.o -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable 
gcc test_parse.o parse_exp.o stack.o token.o error.o ast.o hashtable.o parse_decl.o parse_comp.o parse_stmt.o parse.o eval.o type.o list.o bintree.o str.o -o ./bin/test_parse -O0 -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable  -I/home/max/Projects/Git/CFront/src
/usr/bin/ld: parse_comp.o:/home/max/Projects/Git/CFront/src/eval.h:19: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
/usr/bin/ld: eval.o:/home/max/Projects/Git/CFront/src/eval.c:7: multiple definition of `eval_int_masks'; parse_decl.o:/home/max/Projects/Git/CFront/src/eval.h:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: bin/test_parse] Error 1

Fixed. Mostly compatibility issues with newer version of gcc.