Skip to content

Commit 353df41

Browse files
committed
docs, small fixes
1 parent b06711d commit 353df41

File tree

14 files changed

+5440
-5511
lines changed

14 files changed

+5440
-5511
lines changed

src/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ char* _Owner _Opt CompileText(const char* pszoptions, const char* content)
10331033

10341034
struct report report = { 0 };
10351035
char * s = (char* _Owner _Opt)compile_source(pszoptions, content, &report);
1036-
print_report(&report);
1036+
// print_report(&report);
10371037
return s;
10381038
}
10391039

src/file.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
2-
void main() {
3-
int n;
4-
if (1 && (n = 2, 1))
5-
{
6-
}
1+
int main()
2+
{
3+
const char* s= " \
4+
";
75
}

src/lib.c

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -858,19 +858,19 @@ enum diagnostic_id {
858858
W_DECLARATOR_HIDE = 7,
859859
W_TYPEOF_ARRAY_PARAMETER = 8,
860860
W_ATTRIBUTES = 9,
861-
W_UNUSED_VALUE = 10,
861+
W_EXPRESSION_RESULT_NOT_USED = 10,
862862
W_STYLE = 11,
863-
W_COMMENT = 12,
863+
W_MULTI_LINE_COMMENT = 12,
864864
W_LINE_SLICING = 13,
865865
W_STRING_SLICED = 14,
866866
W_DISCARDED_QUALIFIERS = 15,
867-
W_DECLARATOR_STATE = 16,
867+
W_UNUSED_WARNING_16 = 16,
868868
W_UNINITIALZED = 17,
869869
W_RETURN_LOCAL_ADDR = 18,
870870
W_MUST_USE_ADDRESSOF = 19,
871871
W_ARRAY_INDIRECTION = 20,
872872

873-
W_OWNERSHIP_MISSING_OWNER_QUALIFIER = 21,
873+
W_UNUSED_WARNING_21 = 21,
874874
W_OWNERSHIP_NOT_OWNER = 22,
875875
W_OWNERSHIP_USING_TEMPORARY_OWNER = 23,
876876
W_OWNERSHIP_MOVE_ASSIGNMENT_OF_NON_OWNER = 24,
@@ -884,13 +884,13 @@ enum diagnostic_id {
884884
W_FLOW_LIFETIME_ENDED = 31,
885885
W_FLOW_MOVED = 32,
886886
W_FLOW_NULL_DEREFERENCE = 33,
887-
W_FLOW_MAYBE_NULL_TO_NON_OPT_ARG = 34,
887+
W_FLOW_NOT_USED_34 = 34,
888888
W_FLOW_NULLABLE_TO_NON_NULLABLE = 35,
889889
W_FLOW_DIVIZION_BY_ZERO = 36,
890890

891891

892892
W_DIVIZION_BY_ZERO = 37,
893-
W_CONSTANT_VALUE = 38,
893+
W_UNUSED_WARNING_38 = 38,
894894
W_PASSING_NULL_AS_ARRAY = 39,
895895
W_INCOMPATIBLE_ENUN_TYPES = 40,
896896
W_MULTICHAR_ERROR = 41,
@@ -3012,6 +3012,10 @@ const unsigned char* _Opt escape_sequences_decode_opt(const unsigned char* p, un
30123012
case '"':
30133013
*out_value = '"';
30143014
break;
3015+
3016+
case '\n': //line slicing inside string
3017+
break;
3018+
30153019
default:
30163020
assert(false);
30173021
return NULL;
@@ -9220,7 +9224,7 @@ static struct token_list text_line(struct preprocessor_ctx* ctx, struct token_li
92209224
preprocessor_diagnostic(W_LOCATION, ctx, input_list->head, "you can use \"adjacent\" \"strings\"");
92219225
}
92229226
else if (input_list->head->type == TK_LINE_COMMENT)
9223-
preprocessor_diagnostic(W_COMMENT, ctx, input_list->head, "multi-line //comment");
9227+
preprocessor_diagnostic(W_MULTI_LINE_COMMENT, ctx, input_list->head, "multi-line //comment");
92249228
else
92259229
preprocessor_diagnostic(W_LINE_SLICING, ctx, input_list->head, "unnecessary line-slicing");
92269230
}
@@ -14639,7 +14643,7 @@ int get_diagnostic_phase(enum diagnostic_id w)
1463914643
case W_FLOW_UNINITIALIZED:
1464014644
case W_FLOW_MOVED:
1464114645
case W_FLOW_NULL_DEREFERENCE:
14642-
case W_FLOW_MAYBE_NULL_TO_NON_OPT_ARG:
14646+
case W_FLOW_NOT_USED_34:
1464314647
case W_FLOW_NON_NULL:
1464414648
case W_FLOW_LIFETIME_ENDED:
1464514649
case W_FLOW_DIVIZION_BY_ZERO:
@@ -28776,7 +28780,7 @@ void defer_start_visit_declaration(struct defer_visit_ctx* ctx, struct declarati
2877628780

2877728781
//#pragma once
2877828782

28779-
#define CAKE_VERSION "0.12.53"
28783+
#define CAKE_VERSION "0.12.55"
2878028784

2878128785

2878228786

@@ -37508,28 +37512,23 @@ struct unlabeled_statement* _Owner _Opt unlabeled_statement(struct parser_ctx* c
3750837512
if (p_unlabeled_statement != NULL &&
3750937513
p_unlabeled_statement->jump_statement == NULL &&
3751037514
p_unlabeled_statement->expression_statement != NULL &&
37511-
p_unlabeled_statement->expression_statement->expression_opt &&
37512-
!type_is_void(&p_unlabeled_statement->expression_statement->expression_opt->type) &&
37513-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != ASSIGNMENT_EXPRESSION_ASSIGN &&
37514-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != POSTFIX_FUNCTION_CALL &&
37515-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != POSTFIX_INCREMENT &&
37516-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != POSTFIX_DECREMENT &&
37517-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_EXPRESSION_INCREMENT &&
37518-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_EXPRESSION_DECREMENT &&
37519-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_DECLARATOR_ATTRIBUTE_EXPR &&
37520-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_EXPRESSION_ASSERT)
37521-
{
37522-
if (ctx->current &&
37523-
ctx->current->level == 0)
37515+
p_unlabeled_statement->expression_statement->expression_opt)
37516+
{
37517+
if (p_unlabeled_statement->expression_statement->expression_opt->expression_type == PRIMARY_EXPRESSION_DECLARATOR ||
37518+
p_unlabeled_statement->expression_statement->expression_opt->expression_type == PRIMARY_EXPRESSION_NUMBER)
3752437519
{
37525-
#if 0
37526-
//too many false..alerts.
37527-
//make list of for sure ...
37528-
compiler_diagnostic(W_UNUSED_VALUE,
37529-
ctx,
37530-
p_unlabeled_statement->expression_statement->expression_opt->first_token,
37531-
"expression not used");
37532-
#endif
37520+
if (ctx->current &&
37521+
ctx->current->level == 0)
37522+
{
37523+
//too many false..alerts.
37524+
//make list of for sure ...
37525+
compiler_diagnostic(W_EXPRESSION_RESULT_NOT_USED,
37526+
ctx,
37527+
p_unlabeled_statement->expression_statement->expression_opt->first_token,
37528+
NULL,
37529+
"expression result not used");
37530+
37531+
}
3753337532
}
3753437533
}
3753537534
}
@@ -41969,7 +41968,7 @@ char* _Owner _Opt CompileText(const char* pszoptions, const char* content)
4196941968

4197041969
struct report report = { 0 };
4197141970
char * s = (char* _Owner _Opt)compile_source(pszoptions, content, &report);
41972-
print_report(&report);
41971+
// print_report(&report);
4197341972
return s;
4197441973
}
4197541974

src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <stdlib.h>
1414
#include <time.h>
1515
#include "version.h"
16+
#include "compile.h"
1617

1718
#ifdef _WIN32
1819
#include <crtdbg.h>

src/options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ int get_diagnostic_phase(enum diagnostic_id w)
189189
case W_FLOW_UNINITIALIZED:
190190
case W_FLOW_MOVED:
191191
case W_FLOW_NULL_DEREFERENCE:
192-
case W_FLOW_MAYBE_NULL_TO_NON_OPT_ARG:
192+
case W_FLOW_NOT_USED_34:
193193
case W_FLOW_NON_NULL:
194194
case W_FLOW_LIFETIME_ENDED:
195195
case W_FLOW_DIVIZION_BY_ZERO:

src/options.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ enum diagnostic_id {
2929
W_DECLARATOR_HIDE = 7,
3030
W_TYPEOF_ARRAY_PARAMETER = 8,
3131
W_ATTRIBUTES = 9,
32-
W_UNUSED_VALUE = 10,
32+
W_EXPRESSION_RESULT_NOT_USED = 10,
3333
W_STYLE = 11,
34-
W_COMMENT = 12,
34+
W_MULTI_LINE_COMMENT = 12,
3535
W_LINE_SLICING = 13,
3636
W_STRING_SLICED = 14,
3737
W_DISCARDED_QUALIFIERS = 15,
38-
W_DECLARATOR_STATE = 16,
38+
W_UNUSED_WARNING_16 = 16,
3939
W_UNINITIALZED = 17,
4040
W_RETURN_LOCAL_ADDR = 18,
4141
W_MUST_USE_ADDRESSOF = 19,
4242
W_ARRAY_INDIRECTION = 20,
4343

44-
W_OWNERSHIP_MISSING_OWNER_QUALIFIER = 21,
44+
W_UNUSED_WARNING_21 = 21,
4545
W_OWNERSHIP_NOT_OWNER = 22,
4646
W_OWNERSHIP_USING_TEMPORARY_OWNER = 23,
4747
W_OWNERSHIP_MOVE_ASSIGNMENT_OF_NON_OWNER = 24,
@@ -55,13 +55,13 @@ enum diagnostic_id {
5555
W_FLOW_LIFETIME_ENDED = 31,
5656
W_FLOW_MOVED = 32,
5757
W_FLOW_NULL_DEREFERENCE = 33,
58-
W_FLOW_MAYBE_NULL_TO_NON_OPT_ARG = 34,
58+
W_FLOW_NOT_USED_34 = 34,
5959
W_FLOW_NULLABLE_TO_NON_NULLABLE = 35,
6060
W_FLOW_DIVIZION_BY_ZERO = 36,
6161

6262

6363
W_DIVIZION_BY_ZERO = 37,
64-
W_CONSTANT_VALUE = 38,
64+
W_UNUSED_WARNING_38 = 38,
6565
W_PASSING_NULL_AS_ARRAY = 39,
6666
W_INCOMPATIBLE_ENUN_TYPES = 40,
6767
W_MULTICHAR_ERROR = 41,

src/parser.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8695,28 +8695,23 @@ struct unlabeled_statement* _Owner _Opt unlabeled_statement(struct parser_ctx* c
86958695
if (p_unlabeled_statement != NULL &&
86968696
p_unlabeled_statement->jump_statement == NULL &&
86978697
p_unlabeled_statement->expression_statement != NULL &&
8698-
p_unlabeled_statement->expression_statement->expression_opt &&
8699-
!type_is_void(&p_unlabeled_statement->expression_statement->expression_opt->type) &&
8700-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != ASSIGNMENT_EXPRESSION_ASSIGN &&
8701-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != POSTFIX_FUNCTION_CALL &&
8702-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != POSTFIX_INCREMENT &&
8703-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != POSTFIX_DECREMENT &&
8704-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_EXPRESSION_INCREMENT &&
8705-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_EXPRESSION_DECREMENT &&
8706-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_DECLARATOR_ATTRIBUTE_EXPR &&
8707-
p_unlabeled_statement->expression_statement->expression_opt->expression_type != UNARY_EXPRESSION_ASSERT)
8708-
{
8709-
if (ctx->current &&
8710-
ctx->current->level == 0)
8698+
p_unlabeled_statement->expression_statement->expression_opt)
8699+
{
8700+
if (p_unlabeled_statement->expression_statement->expression_opt->expression_type == PRIMARY_EXPRESSION_DECLARATOR ||
8701+
p_unlabeled_statement->expression_statement->expression_opt->expression_type == PRIMARY_EXPRESSION_NUMBER)
87118702
{
8712-
#if 0
8713-
//too many false..alerts.
8714-
//make list of for sure ...
8715-
compiler_diagnostic(W_UNUSED_VALUE,
8716-
ctx,
8717-
p_unlabeled_statement->expression_statement->expression_opt->first_token,
8718-
"expression not used");
8719-
#endif
8703+
if (ctx->current &&
8704+
ctx->current->level == 0)
8705+
{
8706+
//too many false..alerts.
8707+
//make list of for sure ...
8708+
compiler_diagnostic(W_EXPRESSION_RESULT_NOT_USED,
8709+
ctx,
8710+
p_unlabeled_statement->expression_statement->expression_opt->first_token,
8711+
NULL,
8712+
"expression result not used");
8713+
8714+
}
87208715
}
87218716
}
87228717
}

src/token.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,10 @@ const unsigned char* _Opt escape_sequences_decode_opt(const unsigned char* p, un
16161616
case '"':
16171617
*out_value = '"';
16181618
break;
1619+
1620+
case '\n': //line slicing inside string
1621+
break;
1622+
16191623
default:
16201624
assert(false);
16211625
return NULL;

src/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5586,7 +5586,7 @@ static struct token_list text_line(struct preprocessor_ctx* ctx, struct token_li
55865586
preprocessor_diagnostic(W_LOCATION, ctx, input_list->head, "you can use \"adjacent\" \"strings\"");
55875587
}
55885588
else if (input_list->head->type == TK_LINE_COMMENT)
5589-
preprocessor_diagnostic(W_COMMENT, ctx, input_list->head, "multi-line //comment");
5589+
preprocessor_diagnostic(W_MULTI_LINE_COMMENT, ctx, input_list->head, "multi-line //comment");
55905590
else
55915591
preprocessor_diagnostic(W_LINE_SLICING, ctx, input_list->head, "unnecessary line-slicing");
55925592
}

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#define CAKE_VERSION "0.12.53"
7+
#define CAKE_VERSION "0.12.55"
88

99

1010

0 commit comments

Comments
 (0)