c-decl.c (diagnose_mismatched_decls): Improve error message.
authorEric Christopher <echristo@gcc.gnu.org>
Sun, 13 Jun 2004 16:24:52 +0000 (16:24 +0000)
committerEric Christopher <echristo@gcc.gnu.org>
Sun, 13 Jun 2004 16:24:52 +0000 (16:24 +0000)
2004-06-13  Eric Christopher  <echristo@redhat.com>

* 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  <echristo@redhat.com>

* gcc.dg/noncompile/redecl-1.c: Fix error message.

From-SVN: r83060

gcc/ChangeLog
gcc/c-decl.c
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/redecl-1.c

index 3511122..604eaea 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-13  Eric Christopher  <echristo@redhat.com>
+
+       * 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  <kkojima@gcc.gnu.org>
 
        * config/sh/libgcc-std.ver: Add __unorddf2 and __unordsf2 with
index 5cccefc..2fd53ea 100644 (file)
@@ -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;
 }
-  
+
 \f
 /* 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);
 }
 
index c945f3d..321607c 100644 (file)
@@ -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;
index 9862dea..0aea152 100644 (file)
@@ -1,3 +1,7 @@
+2004-06-13  Eric Christopher  <echristo@redhat.com>
+
+       * gcc.dg/noncompile/redecl-1.c: Fix error message.
+
 2004-06-12  Paul Brook  <paul@codesourcery.com>
 
        * 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  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/12841
@@ -17021,4 +17025,3 @@ rlsruhe.de>
        correspond to c-torture 1.11.
 
        * New file.
-
index f4db950..416c258 100644 (file)
@@ -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" } */
 }
-