diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f5e5829e19dd..e7ea5f8f0761 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-03-13 Joseph S. Myers + + PR c/20402 + * c-parser.c (c_parser_struct_or_union_specifier): Don't fall + through into call to parser_xref_tag after parse error. + (c_parser_struct_declaration): Consistently return NULL_TREE on + error. + 2005-03-12 Daniel Berlin * tree-flow-inline.h (ref_contains_array_ref): New function. diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 6fd09b94be0b..fa62475e943f 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -1827,6 +1827,7 @@ c_parser_struct_or_union_specifier (c_parser *parser) c_parser_error (parser, "expected %<{%>"); ret.spec = error_mark_node; ret.kind = ctsk_tagref; + return ret; } ret = parser_xref_tag (code, ident); return ret; @@ -1883,7 +1884,7 @@ c_parser_struct_declaration (c_parser *parser) specs = build_null_declspecs (); c_parser_declspecs (parser, specs, false, true, true); if (parser->error) - return error_mark_node; + return NULL_TREE; if (!specs->declspecs_seen_p) { c_parser_error (parser, "expected specifier-qualifier-list"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e870a980177b..f2b16c433864 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-03-13 Joseph S. Myers + + PR c/20402 + * gcc.dg/noncompile/920923-1.c: Detail expected diagnostics for + new parser. + 2005-03-12 Tobias Schl"uter PR fortran/20361 diff --git a/gcc/testsuite/gcc.dg/noncompile/920923-1.c b/gcc/testsuite/gcc.dg/noncompile/920923-1.c index b2bc1fdce5bf..4ff008467f5a 100644 --- a/gcc/testsuite/gcc.dg/noncompile/920923-1.c +++ b/gcc/testsuite/gcc.dg/noncompile/920923-1.c @@ -1,94 +1,80 @@ -/* This test case contains a large number of syntactic errors. We - believe the intent of the test is that the compiler simply not - crash. The set of error messages reported is different when the C - parser is generated with bison 1.50 than 1.35. It is not worth - attempting to prevent this. Instead, we use a single dg-error with - a regexp that will match _all_ the errors indiscriminately. The - old error/warning/etc markers are kept around for reference, but - disabled. - - Revisit after new (recursive descent) parser is implemented for C. - -- zw 2002-10-17 */ - -/* { dg-error ".*" "many syntax errors" { target *-*-* } 0 } */ - -typedef BYTE unsigned char; /* { error "syntax error|empty decl" } */ +typedef BYTE unsigned char; /* { dg-error "expected" } */ typedef int item_n; typedef int perm_set; -struct PENT { caddr_t v_addr; };/* { error "parse error|no semicolon" } */ +struct PENT { caddr_t v_addr; };/* { dg-error "expected" } */ typedef struct PENT prec; typedef struct PENT *prec_t; prec_t mem_hash; -BYTE *mem_base; /* { error "parse error|no type" } */ +BYTE *mem_base; /* { dg-error "expected" } */ struct PTE { - BYTE *p_page; /* { error "parse error|no semicolon" } */ + BYTE *p_page; /* { dg-error "expected" } */ perm_set p_perms; -}; /* { error "parse error" } */ +}; typedef struct PTE pte; struct PTP { union { - struct *PTP p_tablep; /* { error "parse error|no semicolon" } */ + struct *PTP p_tablep; /* { dg-error "expected" } */ struct *PTE p_entry; - } u; /* { warning "no type or storage class" } */ + } u; int valid; -}; /* { error "parse error" } */ -typedef struct PTP (u.p_tablep);/* { error "parse error" } */ +}; +typedef struct PTP (u.p_tablep);/* { dg-error "expected" } */ int pfree=0; int pcount=0; void mmu_walk_find(va) -caddr_t va; /* { error "parse error|no type" } */ +caddr_t va; /* { dg-error "expected" } */ { - BYTE *page_addr; - if (mmu_base[Level1(va)]->valid==0x0) { - l1_base = mmu_base[Level1(va)]->(u.p_tablep) = p_alloc(); - mmu_base[Level1(va)]->valid = 0x3; /* { error "parse error" } */ - for (idx=0; idxvalid==0x0) { /* { dg-error "undeclared" } */ + l1_base = mmu_base[Level1(va)]->(u.p_tablep) = p_alloc(); /* { dg-error "expected|undeclared" } */ + mmu_base[Level1(va)]->valid = 0x3; + for (idx=0; idxvalid = 0x0; goto build_level2; } else - l1_base = mmu_base[Level1(va)]->(u.p_tablep); + l1_base = mmu_base[Level1(va)]->(u.p_tablep); /* { dg-error "expected" } */ if (l1_base[Level2(va)]->valid==0x0) { build_level2: - l2_base = l1_base[Level2(va)]->(u.p_tablep) = p_alloc(); - l1_base[Level2(va)]->valid = 0x3; /* { error "parse error" } */ - for (idx=0; idx(u.p_tablep) = p_alloc(); /* { dg-error "expected|undeclared" } */ + l1_base[Level2(va)]->valid = 0x3; + for (idx=0; idxvalid=0x0; - goto build_page; + goto build_page; /* { dg-error "used but not defined" } */ } else - l2_base = mmu_base[Level2(va)]->(u.p_tablep); + l2_base = mmu_base[Level2(va)]->(u.p_tablep); /* { dg-error "expected" } */ - page_addr = l2_base[Level2(va)]->valid;/* { error "undeclared|no type" } */ -} /* { error "parse error" } */ + page_addr = l2_base[Level2(va)]->valid; +} void * a_translate(va_op, v_addr) int va_op; -caddr_t v_addr; /* { error "parse error" } */ +caddr_t v_addr; /* { dg-error "expected" } */ { register prec_t bucket; - register caddr_t p_addr; /* { error "syntax error" } */ - bucket = mem_hash+((((v_addr)>>ITEMBITS))&hash_mask); /* { error "undeclared|for each function" } */ + register caddr_t p_addr; /* { dg-error "expected|undeclared" } */ + bucket = mem_hash+((((v_addr)>>ITEMBITS))&hash_mask); do { - if (bucket->v_addr == ((v_addr)>>ITEMBITS) { /* { error "incomplete type|parse error" } */ + if (bucket->v_addr == ((v_addr)>>ITEMBITS) { /* { dg-error "expected|undeclared|no member" } */ if(!(bucket->perm_set&va_op)) goto prot_fault; return mem_base + v_addr; } - } while((bucket++)->v_addr != ((caddr_t)0)); /* { error "parse error" } */ + } while((bucket++)->v_addr != ((caddr_t)0)); /* { dg-error "expected|undeclared|no member" } */ page_miss: - p_addr = (--bucket)->p_addr; /* { error "undeclared|pointer to" } */ + p_addr = (--bucket)->p_addr; /* { dg-error "no member" } */ page_type: switch (p_addr) { - case BUCKET_FULL: /* { error "undeclared" } */ + case BUCKET_FULL: /* { dg-error "undeclared" } */ enlarge_hash_table(mem_hash); - case((caddr_t)0): /* { error "undeclared|parse error" } */ + case((caddr_t)0): /* { dg-error "expected" } */ p_addr = fill_item_entry(va_op, v_addr); goto page_type; - case((caddr_t)1): /* { error "parse error" } */ + case((caddr_t)1): /* { dg-error "expected" } */ default: ((void)(((0))?0:(__eprintf("Failed assertion`%s'at line%d of`%s'.\n", "FALSE", 327, "b.c"), 0))); @@ -104,9 +90,9 @@ int hash_size; register int idx; bucket = hasht; for(idx=(hash_size*3)-1; idx>=0; idx--) { - bucket->v_addr = ((caddr_t)0);/* { error "undeclared|pointer to|parse error" } */ - bucket->p_addr = ((caddr_t)0);/* { error "pointer to|parse error" } */ - bucket->perm_set = VA_EMPTY; /* { error "undeclared|pointer to" } */ + bucket->v_addr = ((caddr_t)0);/* { dg-error "undeclared|expected|no member" } */ + bucket->p_addr = ((caddr_t)0);/* { dg-error "no member|expected" } */ + bucket->perm_set = VA_EMPTY; /* { dg-error "undeclared|no member" } */ } } @@ -115,21 +101,21 @@ extern void *calloc(__SIZE_TYPE__, __SIZE_TYPE__); void init_mem() { - mem_base = (BYTE *) calloc(1024, (1<<13)); /* { error "undeclared|parse error" } */ - ((void)((mem_base != (BYTE *)0) /* { error "parse error" } */ + mem_base = (BYTE *) calloc(1024, (1<<13)); /* { dg-error "undeclared|expected" } */ + ((void)((mem_base != (BYTE *)0) /* { dg-error "expected" } */ ? 0 : (__eprintf("Failed assertion`%s'at line%d of`%s'.\n", "mem_base != (BYTE *)0", 366, "b.c"), 0))); - hash_num = INIT_NUM_ENTRIES * 3; /* { error "undeclared" } */ - mem_hash = (prec_t) calloc(hash_num, sizeof(prec)); /* { error "incomplete type" } */ + hash_num = INIT_NUM_ENTRIES * 3; /* { dg-error "undeclared" } */ + mem_hash = (prec_t) calloc(hash_num, sizeof(prec)); ((void)((mem_hash != (prec_t)0) ? 0 : (__eprintf("Failed assertion`%s'at line%d of`%s'.\n", "mem_hash != (prec_t)0", 370, "b.c"), 0))); flush_hash(mem_hash, 32); - build_ptables(mem_base, 1024*(1<<13)); /* { bogus "integer overflow" "int smaller than 32 bits" } */ + build_ptables(mem_base, 1024*(1<<13)); /* { dg-bogus "integer overflow" "int smaller than 32 bits" } */ } struct tm {