Skip to content

Commit

Permalink
Parser: remove incorrect assert
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas committed Feb 13, 2024
1 parent 12748fd commit 8b326ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ fn diagnoseIncompleteDefinitions(p: *Parser) !void {
const tys = node_slices.items(.ty);
const data = node_slices.items(.data);

const err_start = p.comp.diagnostics.list.items.len;
for (p.decl_buf.items) |decl_node| {
const idx = @intFromEnum(decl_node);
switch (tags[idx]) {
Expand All @@ -666,8 +665,6 @@ fn diagnoseIncompleteDefinitions(p: *Parser) !void {
try p.errStr(.tentative_definition_incomplete, tentative_def_tok, type_str);
try p.errStr(.forward_declaration_here, data[idx].decl_ref, type_str);
}
const errors_added = p.comp.diagnostics.list.items.len - err_start;
assert(errors_added == 2 * p.tentative_defs.count()); // Each tentative def should add an error + note
}

/// root : (decl | assembly ';' | staticAssert)*
Expand Down
11 changes: 11 additions & 0 deletions test/cases/incomplete types.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ void incomplete_enum_float(void) {

void incomplete_unspecified_variable_len_array(struct S b[1][*]);

void f1(struct Foo *a) { } /* should produce `warning: declaration of 'struct Foo' will not be visible outside of this function [-Wvisibility]` instead of tentative definition error */

struct Foo f;

#define TESTS_SKIPPED 1

#define EXPECTED_ERRORS "incomplete types.c:4:5: error: dereferencing pointer to incomplete type 'struct S'" \
"incomplete types.c:5:11: error: dereferencing pointer to incomplete type 'struct S'" \
"incomplete types.c:8:5: error: dereferencing pointer to incomplete type 'union U'" \
Expand All @@ -56,3 +62,8 @@ void incomplete_unspecified_variable_len_array(struct S b[1][*]);
"incomplete types.c:34:13: error: statement requires expression with integer type ('struct node' invalid)" \
"incomplete types.c:40:12: error: variable has incomplete type 'enum E'" \
"incomplete types.c:44:58: error: array has incomplete element type 'struct S [*]'" \
"incomplete types.c:48:12: error: tentative definition has type 'struct Foo' that is never completed" \
"incomplete types.c:46:16: note: forward declaration of 'struct Foo'" \
"incomplete types.c:48:12: error: tentative definition has type 'struct Foo' that is never completed" \
"incomplete types.c:48:8: note: forward declaration of 'struct Foo'" \

0 comments on commit 8b326ec

Please sign in to comment.