Commit graph

493 commits

Author SHA1 Message Date
Dale Weiler
d51a6ab3db Whitespace 2012-12-23 09:10:31 +00:00
Dale Weiler
5bc815c63f Revert "Whitespace fixes"
This reverts commit 4580dcf1ea.
2012-12-23 09:10:07 +00:00
Dale Weiler
4580dcf1ea Whitespace fixes 2012-12-23 08:42:53 +00:00
Dale Weiler
c3964cf29d Make compiler and virtual-machine compile as C++ code, also removed gmqcc_voidptr hack. 2012-12-23 07:51:19 +00:00
Dale Weiler
d35d953a91 Remove parser_compile_string_len, and make parser_compiler_string take an additional length argument. 2012-12-23 07:22:15 +00:00
Wolfgang Bumiller
e8cd9411b0 -Wunknown-attribute; and don't error on unknown attributes 2012-12-22 18:16:41 +01:00
Wolfgang Bumiller
7cf0ba5aa8 'noreturn' is now an attribute and parsed as [[noreturn]] 2012-12-22 18:09:56 +01:00
Wolfgang Bumiller
1f070b740f -ffalse-empty-strings in && and || 2012-12-22 17:31:31 +01:00
Wolfgang Bumiller
0fe71af4ce -fcorrect-logic now handles only vectors 2012-12-22 17:18:37 +01:00
Wolfgang Bumiller
8459895fdd Fix a bug with -fperl-logic and -fcorrect-logic 2012-12-22 16:25:19 +01:00
Dale Weiler
fa401b6f56 Cleanups and make compile with clang again with no warnings. 2012-12-22 08:22:50 +00:00
Dale Weiler
7d2a2f2ade cleanups and fixes that cppcheck found 2012-12-22 08:07:54 +00:00
Wolfgang Bumiller
93341dd009 *sigh* 2012-12-20 20:57:05 +01:00
Wolfgang Bumiller
a6547a15f3 no need to check the array, the 2nd NOT is a NOT_F 2012-12-20 20:56:49 +01:00
Wolfgang Bumiller
ccbccad994 fix -fcorrect-logic to use double-not instead of a single one - wow that was a bad one 2012-12-20 20:55:56 +01:00
Wolfgang Bumiller
68c4070f62 Fix the -fcorrect-logic condition 2012-12-20 20:40:59 +01:00
Wolfgang Bumiller
0988b731b7 Fix -fcorrect-logic 2012-12-20 20:33:05 +01:00
Wolfgang Bumiller
4f9c7861ec For loops may have an empty condition - don't try processing a NULL 2012-12-20 20:23:35 +01:00
Wolfgang Bumiller
a985a5cab1 while/for/do now all use process_condition, ast_loop got 2 new parameters for more efficient translation 2012-12-20 20:22:31 +01:00
Wolfgang Bumiller
d72cb42b08 process_condition function used by parse_if - need to still add it to loops 2012-12-20 19:51:30 +01:00
Wolfgang Bumiller
34063108a6 since unary not doesn't fold these, remove them from immediate_is_true 2012-12-20 19:19:12 +01:00
Wolfgang Bumiller
4319922b3c introducing an immediate_is_true which follows the new -f flags on strings and vector truthfulness, used in logic-op constant folding; const folding now disabled for functions-constants on NOT because it's stupid 2012-12-20 19:18:22 +01:00
Wolfgang Bumiller
6b9eff19f1 unary not now uses NOT_F with -ftrue-empty-strings 2012-12-20 19:04:56 +01:00
Wolfgang Bumiller
b85441d6af Making logical 'and' and 'or' use NOT_ in -fcorrect-logic for both operands normally, but only for the first with -fperl-logic 2012-12-20 19:00:23 +01:00
Wolfgang Bumiller
d76e6b103d ast_return needs the correct context... 2012-12-20 15:01:19 +01:00
Wolfgang (Blub) Bumiller
57aaf57dfc Revert "Fix FTFBS stuff"
This reverts commit 2cc51b8eb0.
2012-12-19 22:15:38 +01:00
Dale Weiler
2cc51b8eb0 Fix FTFBS stuff 2012-12-19 21:05:40 +00:00
Wolfgang (Blub) Bumiller
664b6d6604 'noreturn' is - for now - a keyword, and used just like noref/var/const, to mark a function as not-returning 2012-12-19 20:56:22 +01:00
Wolfgang (Blub) Bumiller
ba434c8e22 removing ast_expression_common.variadic, adding ast_expression_common.flags, added AST_FLAG_VARIADIC and AST_FLAG_NORETURN 2012-12-19 20:45:48 +01:00
Rudolf Polzer
acf4da9385 Fixes for some minor bugs clang-analyzer and cppcheck found
Signed-off-by: Dale Weiler <killfieldengine@gmail.com>
2012-12-18 16:54:51 +00:00
Wolfgang (Blub) Bumiller
2a61a65ce0 -fperl-logic now doesn't allow logic ops with operands of different types, but therefore uses the correct output type 2012-12-18 16:56:22 +01:00
Wolfgang (Blub) Bumiller
9b9fbb6e3b Added intrinsic: __builtin_debug_typestring(expr) to get the type of an expression as string 2012-12-18 16:52:30 +01:00
Wolfgang (Blub) Bumiller
b337f630c8 Remove a TODO message 2012-12-18 16:36:06 +01:00
Wolfgang (Blub) Bumiller
b7117e08ce parsewarning and genwarning to use vcompile_warning 2012-12-17 18:26:26 +01:00
Dale Weiler
8e0515de44 Added -Wunknown-pragmas 2012-12-17 16:14:43 +00:00
Wolfgang (Blub) Bumiller
f0687adbaa Error when the assignop for an assignment is invalid, eg. when trying to assign arrays 2012-12-17 16:00:08 +01:00
Wolfgang (Blub) Bumiller
f9b1d057b5 Moving all the global opts_ variables into a struct, now there's one global 'opts' struct 2012-12-06 13:23:53 +01:00
Wolfgang (Blub) Bumiller
04a57d871e unexpected typename error when there are typenames in an expression 2012-12-05 17:14:44 +01:00
Wolfgang (Blub) Bumiller
8777624fe2 ast_block_add_expr now lets the block fully adopt the type of the added expression 2012-12-05 12:57:00 +01:00
Wolfgang (Blub) Bumiller
f140251e85 s/parser_sy_pop/parser_sy_apply_operator/ 2012-12-04 21:04:14 +01:00
Wolfgang (Blub) Bumiller
8e077f378e -Werror now changes the word 'warning' into 'error' 2012-12-04 12:54:53 +01:00
Wolfgang (Blub) Bumiller
0e4e81d94f Parsing the 'noref' keyword; this also gets rid of some code duplication 2012-12-04 12:17:43 +01:00
Wolfgang (Blub) Bumiller
88a4721de7 Parsing noref-pragma 2012-12-03 20:37:02 +01:00
Wolfgang (Blub) Bumiller
02ec45363e Get rid of some code duplication 2012-12-02 17:57:08 +01:00
Wolfgang (Blub) Bumiller
8188d0b9f7 Sanity check for -Wternary-precedence 2012-12-01 12:36:54 +01:00
Wolfgang (Blub) Bumiller
ed4c513b1e -Wternary-precedence; *sight* this is tough 2012-12-01 12:35:46 +01:00
Wolfgang (Blub) Bumiller
b966cd4f4d More ternary fixes 2012-12-01 00:50:04 +01:00
Wolfgang (Blub) Bumiller
43c0343755 Offsetting builtins so we can use 'if builtin!=0' as condition but also allow a '#0' builtin 2012-12-01 00:36:24 +01:00
Wolfgang (Blub) Bumiller
75ab0e6663 and 'const' is a keyword, not an ident 2012-12-01 00:33:07 +01:00
Wolfgang (Blub) Bumiller
ac9d68387c var const / const var - both need to be allowed 2012-12-01 00:32:18 +01:00
Wolfgang (Blub) Bumiller
d52879315d some SYA fix; adding optional variable parsing to the head of a switch block 2012-12-01 00:31:00 +01:00
Wolfgang (Blub) Bumiller
8d014cc6eb changing parse_statement_or_block to return a bool and put the output block into a pointer, so that NULL can still be possible 2012-11-30 21:31:19 +01:00
Wolfgang (Blub) Bumiller
cda62cef20 apparently #0 is a valid builtin number, used for some NULL funcs 2012-11-30 21:25:18 +01:00
Wolfgang (Blub) Bumiller
2a3e7c1cff field constants - revert globals generated after fields 2012-11-30 21:11:25 +01:00
Wolfgang (Blub) Bumiller
316298650e remember if an ast_value is a field-declaration, build fields before globals 2012-11-30 21:03:57 +01:00
Wolfgang (Blub) Bumiller
f587e9cfb3 remove array-field without parens warning since it seems to not be broken in fteqcc anymore 2012-11-30 14:47:55 +01:00
Wolfgang (Blub) Bumiller
535fd5744b lex_ctx of a return will be at the return keyword now 2012-11-30 14:42:18 +01:00
Wolfgang (Blub) Bumiller
207293bf74 revert 1 of the error messages 2012-11-30 14:37:54 +01:00
Wolfgang (Blub) Bumiller
321a1fe0d6 Keep track of the beginning of a block 2012-11-30 14:37:23 +01:00
Wolfgang (Blub) Bumiller
eec61af381 mark vectors as used when their members are used 2012-11-30 14:30:25 +01:00
Wolfgang (Blub) Bumiller
600ecda860 Set the full const/var qualifier; only generate warnings about unimplemented functions if they have no qualifier at all 2012-11-30 14:05:25 +01:00
Wolfgang (Blub) Bumiller
5e23e8296d don't just store a 'bool constant' in the ast/ir, store the complete qualifier: 'int cvq', moved CV_ defines into gmqcc.h 2012-11-30 13:47:28 +01:00
Wolfgang (Blub) Bumiller
8e043c8447 Remove the 'warnreturn' parameter in some parser functions 2012-11-30 12:37:46 +01:00
Wolfgang (Blub) Bumiller
a58061464e actually removing -Wmissing-return-values from parser.c and enabling the ast code for it 2012-11-30 12:11:36 +01:00
Wolfgang (Blub) Bumiller
08551eefba Fix a small typo 2012-11-26 14:05:31 +01:00
Dale Weiler
77272da718 opval is asserted .. need (void) to hide warning when NDEBUG 2012-11-26 02:12:50 +00:00
Wolfgang (Blub) Bumiller
ec2ff09eff operator &~= must not cause the generated binstore to free the destination twice 2012-11-26 00:15:07 +01:00
Wolfgang (Blub) Bumiller
0af62801f4 Don't add redeclared globals a second time 2012-11-25 23:35:31 +01:00
Wolfgang (Blub) Bumiller
38df8b5e40 Another case for -fassign-function-types 2012-11-25 23:28:47 +01:00
Wolfgang (Blub) Bumiller
0d3896ca54 introducing -fassign-function-types, previously guarded by std==qcc this is now the flag to cause a warning (-Wassign-function-types) instead of an error when assigning functions of wrong types 2012-11-25 23:27:48 +01:00
Wolfgang (Blub) Bumiller
2f5a26a4de __builtin_debug_printtype directive... helped me down tracking a bug: parsing typedeffed types in parameter lists properly now 2012-11-25 22:57:11 +01:00
Wolfgang (Blub) Bumiller
08ef8bd045 Only check the ast-type of a switch case, not if it's an ACTUAL constant, fteqcc doesn't either... grrr 2012-11-25 22:40:35 +01:00
Wolfgang (Blub) Bumiller
10f49a38ca actually handle unary plus... 2012-11-25 22:38:52 +01:00
Wolfgang (Blub) Bumiller
42bd37a2e8 Ah right, 'var' is not an actual keyword, support TOKEN_IDENT-var inside functions 2012-11-25 22:26:28 +01:00
Wolfgang (Blub) Bumiller
f1bbdb7d45 Use the correct default cv-qualifier on locals 2012-11-25 22:16:08 +01:00
Wolfgang (Blub) Bumiller
c62e0a93eb Allow 'var' in functions... even there initialized locals seem to be constant by default... laaaaaaaame 2012-11-25 22:15:08 +01:00
Wolfgang (Blub) Bumiller
797ceb9e04 handling TOKEN_CHARCONST - -Wmultibyte-character 2012-11-25 22:11:21 +01:00
Wolfgang (Blub) Bumiller
e2602e6b87 Filling up remaining gotos at the end of a function for when the label is defined after the goto; erroring for missing labels 2012-11-25 21:56:38 +01:00
Wolfgang (Blub) Bumiller
24f9b63475 parsing goto 2012-11-25 21:53:14 +01:00
Wolfgang (Blub) Bumiller
474d8bd6f0 ast_label, and labels later used for goto 2012-11-25 21:27:14 +01:00
Wolfgang (Blub) Bumiller
336d91494f temporarily disable the 'constant' flag when parsing the initializer to avoid the 'assigning to constant' error in a block-local constant 2012-11-25 21:10:43 +01:00
Wolfgang (Blub) Bumiller
22173df7bd Allow 'const' within function bodies 2012-11-25 21:08:30 +01:00
Wolfgang (Blub) Bumiller
3424b7227b Set the output to NULL always before parsing stuff 2012-11-25 20:48:06 +01:00
Wolfgang (Blub) Bumiller
4513fc4d0b fix wrong parameter order in parse_variable calls, dammit I hate how 'bool' and 'int' are implicitly convertible here 2012-11-25 20:29:12 +01:00
Wolfgang (Blub) Bumiller
1b72cb264a more on CV_CONST/CV_VAR, initializers to check 'constant' not just 'hasvalue' 2012-11-25 20:25:39 +01:00
Wolfgang (Blub) Bumiller
6cd432a909 const/variable qualifier flag for parse_variable 2012-11-25 20:22:47 +01:00
Wolfgang (Blub) Bumiller
779c974511 Allow dangling semicolons for now 2012-11-25 20:18:40 +01:00
Wolfgang (Blub) Bumiller
f2887f1208 a '(void)' parameter list does not mean 1 parameter of type void, but empty... xonotic needs this 2012-11-25 19:44:21 +01:00
Wolfgang (Blub) Bumiller
b59401db1b fixed: -frelaxed-switch check was in the wrong position 2012-11-25 19:42:16 +01:00
Wolfgang (Blub) Bumiller
353b1f945f assignment to constant error 2012-11-25 19:37:31 +01:00
Wolfgang (Blub) Bumiller
39f572fe99 constant flag, -finitialized-nonconstants to turn initialized globals into mutable variables 2012-11-25 19:35:00 +01:00
Wolfgang (Blub) Bumiller
6e400ca81f ast: isconst->hasvalue, const keyword will set the const flag 2012-11-25 19:30:10 +01:00
Wolfgang (Blub) Bumiller
55aa53beca Parse the 'not' keyword in if as TOKEN_IDENT 2012-11-25 19:20:00 +01:00
Wolfgang (Blub) Bumiller
ca033e5acd Some side-effect propagation for better warnings, so that comma-operators with assignments in them don't cause the -Weffectless-statement warning, and fixing ternary precedence for fte operator list 2012-11-25 19:19:36 +01:00
Wolfgang (Blub) Bumiller
63d89f9f5a Allow regular AND used on non-float types 2012-11-25 18:56:22 +01:00
Wolfgang (Blub) Bumiller
2c0a9d78df Guard translatable strings by -ftranslatable-strings, defaults to ON with -std=fteqcc 2012-11-25 18:25:01 +01:00
Wolfgang (Blub) Bumiller
66317aaef9 update noops flag while parsing a translatable string 2012-11-25 18:23:48 +01:00
Wolfgang (Blub) Bumiller
7838e772de Translatable string constants 2012-11-25 18:22:00 +01:00
Wolfgang (Blub) Bumiller
0df394dcbc parser_const_string can now create a translatable string 2012-11-25 18:17:08 +01:00
Wolfgang (Blub) Bumiller
e22af32805 Fix parsing of multi-dot field types 2012-11-25 17:43:13 +01:00
Wolfgang (Blub) Bumiller
2884556fe3 multiple dots to start a field type, ie ..float for a fieldpointer field 2012-11-25 17:37:54 +01:00
Wolfgang (Blub) Bumiller
b5d6f454a4 moving cleanvar=false out of a condition 2012-11-25 16:20:22 +01:00
Wolfgang (Blub) Bumiller
2da37129d7 a more verbose error 2012-11-25 15:58:10 +01:00
Wolfgang (Blub) Bumiller
4b619ce1cd -Wconst-var 2012-11-25 15:56:13 +01:00
Wolfgang (Blub) Bumiller
f6a374c1d5 free the _locals vector 2012-11-25 15:31:26 +01:00
Wolfgang (Blub) Bumiller
3c0c002e2f Fix a missing uninitialized value which caused typedefs within functions to cause a segfault 2012-11-25 15:30:31 +01:00
Wolfgang (Blub) Bumiller
63d9e44f56 Allow typedefs to shadow defs of previous scopes 2012-11-25 15:27:22 +01:00
Wolfgang (Blub) Bumiller
b851f542ac Implementing typedef 2012-11-25 15:21:52 +01:00
Wolfgang (Blub) Bumiller
d69b576d6b Fix some uninitialized values 2012-11-25 13:55:29 +01:00
Wolfgang (Blub) Bumiller
613e1e7247 Change the parser to use the hashtable functions 2012-11-25 13:23:37 +01:00
Dale Weiler
5c0a62be96 Add respective license headers + some cleanups 2012-11-24 21:22:35 +00:00
Wolfgang (Blub) Bumiller
86f3ef2194 turn the message about global variable double-declaration into a warning instead of an error on std != gmqcc 2012-11-23 22:30:35 +01:00
Wolfgang (Blub) Bumiller
39b8b6a660 warn about double function declarations... 2012-11-23 22:22:22 +01:00
Wolfgang (Blub) Bumiller
2bc99076cf 'var' is now no keyword anymore, :\ 2012-11-23 22:07:35 +01:00
Wolfgang (Blub) Bumiller
1c7e9c5fde handling 'const' - still need correct separation of constant and just initialized later when we distinguish between them 2012-11-23 21:52:16 +01:00
Wolfgang (Blub) Bumiller
6df6906ed2 Adding an unrecognized keywords error 2012-11-23 21:41:50 +01:00
Wolfgang (Blub) Bumiller
0d33939b1b operator &~= 2012-11-23 14:39:05 +01:00
Wolfgang (Blub) Bumiller
122e80cc4d operators &= and |= 2012-11-23 14:28:11 +01:00
Wolfgang (Blub) Bumiller
553f3df5df *= and /= operators 2012-11-23 14:24:58 +01:00
Wolfgang (Blub) Bumiller
1223e04e05 correcting an error message 2012-11-23 12:28:51 +01:00
Wolfgang (Blub) Bumiller
f22f1af891 Suffix operators, and remembering the const-float-1 in parser_t 2012-11-23 12:25:13 +01:00
Wolfgang (Blub) Bumiller
4079835c7e Parsing of suffix operators, NOTE: applied like prefix operators just to get it committed in a compilable state 2012-11-23 11:57:08 +01:00
Wolfgang (Blub) Bumiller
38f5090778 Prefix ++,-- 2012-11-23 11:52:03 +01:00
Wolfgang (Blub) Bumiller
9a43eb6370 a type_name -> ast_type_to_string conversion 2012-11-23 11:45:22 +01:00
Dale Weiler
c748293ccb Use memcmp for comparing doubles 2012-11-23 06:41:06 +00:00
Dale Weiler
b5507b3127 Make it compile with -Wall and -pedantic 2012-11-23 02:23:22 +00:00
Wolfgang (Blub) Bumiller
905ca8819b unused params in parser.c 2012-11-22 21:44:09 +01:00
Wolfgang (Blub) Bumiller
dfde3a583c Remove unused macro 2012-11-22 21:10:37 +01:00
Wolfgang (Blub) Bumiller
07d5686a47 Fixing shadows in parser.c - moving generate_checksum over the static parser global 2012-11-22 20:47:46 +01:00
Wolfgang (Blub) Bumiller
6983142c4d -dump vs -dumpfin; to see the IR before and after finalizing functions 2012-11-21 21:53:38 +01:00
Wolfgang (Blub) Bumiller
9c8dc43775 error if the ternary operands aren't of the same type - except for the first one of course 2012-11-21 20:56:51 +01:00
Wolfgang (Blub) Bumiller
0787038934 check 'ternaries' count 2012-11-21 20:50:27 +01:00
Wolfgang (Blub) Bumiller
90bd91e294 Utilizing vec_last more 2012-11-21 20:44:43 +01:00
Wolfgang (Blub) Bumiller
55c2148016 operator handling for ternary 2012-11-21 20:41:26 +01:00
Wolfgang (Blub) Bumiller
11f1af78d5 Removing some obsolete messages 2012-11-21 20:40:10 +01:00
Wolfgang (Blub) Bumiller
e0ddf32d2e parsing the ternary 2012-11-21 20:36:42 +01:00
Wolfgang (Blub) Bumiller
f4043faf0b -frelaxed-switch to enable switch on non-constant cases 2012-11-19 22:27:58 +01:00
Wolfgang (Blub) Bumiller
4649c12fa9 Parsing of switches 2012-11-19 22:06:29 +01:00
Wolfgang (Blub) Bumiller
b72900214b fix a warning and remove unused variables 2012-11-19 19:44:26 +01:00
Wolfgang (Blub) Bumiller
ea75003cf4 break and continue support 2012-11-19 19:39:52 +01:00
Wolfgang (Blub) Bumiller
2d8bf20d43 moving 'return' parsing into a function 2012-11-19 19:22:00 +01:00
Wolfgang (Blub) Bumiller
f023004a67 Make functions copy their extparams 2012-11-18 20:06:28 +01:00
Wolfgang (Blub) Bumiller
e8d1e5dbc0 Make the >8 parameter message a warning 2012-11-18 19:19:38 +01:00
Wolfgang (Blub) Bumiller
0330b082a2 The ftepp now always outputs into a string buffer, with -E the buffer will be dumped to stdout or the via -o specified file, without -E it'll be passed to the parser to be compiled 2012-11-18 13:33:53 +01:00
Wolfgang (Blub) Bumiller
f0d56d07fe Merge branch 'master' into ftepp 2012-11-18 13:06:29 +01:00
Wolfgang (Blub) Bumiller
cec58b53e4 Collect accessor functions in the parser so they can later be deleted, fixed that leak 2012-11-18 13:06:16 +01:00
Wolfgang (Blub) Bumiller
f47a20aa53 Removing some code duplication 2012-11-18 13:00:18 +01:00
Wolfgang (Blub) Bumiller
2b65ea599f Some printf/con_out/con_err conversions, guarded some outputs with not-opts_pp_only so the -E switch can print to stdout normally 2012-11-18 11:43:46 +01:00
Wolfgang (Blub) Bumiller
906f319673 Replaced it all... 2012-11-15 18:32:09 +01:00
Dale Weiler
2e84cc0b41 Use new console system everywhere. 2012-11-15 00:28:46 +00:00