From 118a3a8ba8497b0b68ebe0f875ce940d84a7315e Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Sun, 13 Jun 2004 16:24:52 +0000 Subject: [PATCH] c-decl.c (diagnose_mismatched_decls): Improve error message. 2004-06-13 Eric Christopher * c-decl.c (diagnose_mismatched_decls): Improve error message. Remove unused code. * c-typeck.c (comptypes): Add location in standard we're checking. 2004-06-13 Eric Christopher * gcc.dg/noncompile/redecl-1.c: Fix error message. From-SVN: r83060 --- gcc/ChangeLog | 6 +++ gcc/c-decl.c | 51 +++++++--------------- gcc/c-typeck.c | 2 +- gcc/testsuite/ChangeLog | 9 ++-- gcc/testsuite/gcc.dg/noncompile/redecl-1.c | 3 +- 5 files changed, 30 insertions(+), 41 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3511122e359..604eaea921c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-06-13 Eric Christopher + + * c-decl.c (diagnose_mismatched_decls): Improve error message. + Remove unused code. + * c-typeck.c (comptypes): Add location in standard we're checking. + 2004-06-13 Kaz Kojima * config/sh/libgcc-std.ver: Add __unorddf2 and __unordsf2 with diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 5cccefc6d68..2fd53ea7b50 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -603,7 +603,7 @@ push_scope (void) scope->depth--; sorry ("GCC supports only %u nested scopes\n", scope->depth); } - + current_scope = scope; keep_next_level_flag = false; } @@ -688,7 +688,7 @@ pop_scope (void) /* Labels go in BLOCK_VARS. */ TREE_CHAIN (p) = BLOCK_VARS (block); BLOCK_VARS (block) = p; - + #ifdef ENABLE_CHECKING if (I_LABEL_BINDING (b->id) != b) abort (); #endif @@ -776,7 +776,7 @@ pop_scope (void) } } - + /* Dispose of the block that we just made inside some higher level. */ if ((scope->function_body || scope == file_scope) && context) { @@ -1138,7 +1138,10 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, } else { - error ("%Jconflicting types for '%D'", newdecl, newdecl); + if (TYPE_QUALS (newtype) != TYPE_QUALS (oldtype)) + error ("%J conflicting type qualifiers for '%D'", newdecl, newdecl); + else + error ("%Jconflicting types for '%D'", newdecl, newdecl); diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype); locate_old_decl (olddecl, error); return false; @@ -1152,7 +1155,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, { if (DECL_IN_SYSTEM_HEADER (newdecl) || DECL_IN_SYSTEM_HEADER (olddecl)) return true; /* Allow OLDDECL to continue in use. */ - + error ("%Jredefinition of typedef '%D'", newdecl, newdecl); locate_old_decl (olddecl, error); return false; @@ -1182,7 +1185,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, /* Discard the old built-in function. */ return false; } - + if (DECL_INITIAL (newdecl)) { if (DECL_INITIAL (olddecl) @@ -1365,28 +1368,6 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, locate_old_decl (olddecl, error); return false; } - - /* These bits are only type qualifiers when applied to objects. */ - if (TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)) - { - if (TREE_THIS_VOLATILE (newdecl)) - pedwarn ("%Jvolatile declaration of '%D' follows " - "non-volatile declaration", newdecl, newdecl); - else - pedwarn ("%Jnon-volatile declaration of '%D' follows " - "volatile declaration", newdecl, newdecl); - pedwarned = true; - } - if (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)) - { - if (TREE_READONLY (newdecl)) - pedwarn ("%Jconst declaration of '%D' follows " - "non-const declaration", newdecl, newdecl); - else - pedwarn ("%Jnon-const declaration of '%D' follows " - "const declaration", newdecl, newdecl); - pedwarned = true; - } } /* Optional warning for completely redundant decls. */ @@ -1677,7 +1658,7 @@ duplicate_decls (tree newdecl, tree olddecl) merge_decls (newdecl, olddecl, newtype, oldtype); return true; } - + /* Check whether decl-node NEW shadows an existing declaration. */ static void @@ -2215,7 +2196,7 @@ lookup_tag (enum tree_code code, tree name, int thislevel_only) /* For our purposes, a tag in the external scope is the same as a tag in the file scope. (Primarily relevant to Objective-C and its builtin structure tags, which get pushed before the - file scope is created.) */ + file scope is created.) */ if (b->contour == current_scope || (current_scope == file_scope && b->contour == external_scope)) thislevel = 1; @@ -3309,7 +3290,7 @@ check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name) if (TREE_CODE (*type) == ENUMERAL_TYPE) { struct lang_type *lt = TYPE_LANG_SPECIFIC (*type); - if (!lt + if (!lt || w < min_precision (lt->enum_min, TYPE_UNSIGNED (*type)) || w < min_precision (lt->enum_max, TYPE_UNSIGNED (*type))) warning ("`%s' is narrower than values of its type", name); @@ -4842,7 +4823,7 @@ get_parm_info (bool ellipsis) /* The %s will be one of 'struct', 'union', or 'enum'. */ warning ("anonymous %s declared inside parameter list", keyword); - + if (! explained_incomplete_types) { warning ("its scope is only this definition or declaration," @@ -6336,7 +6317,7 @@ finish_function (void) /* Genericize before inlining. Delay genericizing nested functions until their parent function is genericized. Since finalizing requires GENERIC, delay that as well. */ - + if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node) { if (!decl_function_context (fndecl)) @@ -6656,14 +6637,14 @@ c_write_global_declarations_1 (tree globals) tree *vec = xmalloc (sizeof (tree) * len); size_t i; tree decl; - + /* Process the decls in the order they were written. */ for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) vec[i] = decl; wrapup_global_declarations (vec, len); check_global_declarations (vec, len); - + free (vec); } diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c945f3d3bd4..321607c2263 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -598,7 +598,7 @@ comptypes (tree type1, tree type2, int flags) if (TREE_CODE (t1) != TREE_CODE (t2)) return 0; - /* Qualifiers must match. */ + /* Qualifiers must match. C99 6.7.3p9 */ if (TYPE_QUALS (t1) != TYPE_QUALS (t2)) return 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9862dead242..0aea15208d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-06-13 Eric Christopher + + * gcc.dg/noncompile/redecl-1.c: Fix error message. + 2004-06-12 Paul Brook * gfortran.fortran-torture/execute/contained_3.f90: New test. @@ -11,8 +15,8 @@ PR fortran/14957 * gfortran.fortran-torture/execute/stack_varsize.f90: Correct - syntax errors in end statements of contained subroutines. - + syntax errors in end statements of contained subroutines. + 2004-06-12 Tobias Schlueter PR fortran/12841 @@ -17021,4 +17025,3 @@ rlsruhe.de> correspond to c-torture 1.11. * New file. - diff --git a/gcc/testsuite/gcc.dg/noncompile/redecl-1.c b/gcc/testsuite/gcc.dg/noncompile/redecl-1.c index f4db95013e2..416c258c0d4 100644 --- a/gcc/testsuite/gcc.dg/noncompile/redecl-1.c +++ b/gcc/testsuite/gcc.dg/noncompile/redecl-1.c @@ -5,6 +5,5 @@ int foo () { int bar; /* { dg-error "previous.*decl" "previous.*decl" } */ - volatile int bar; /* { dg-error "conflicting types" "conflicting types" } */ + volatile int bar; /* { dg-error "conflicting type qualifiers" "conflicting type qualifiers" } */ } -