aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1994-04-18 17:56:01 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1994-04-18 17:56:01 -0400
commit2af6a433d9630f5fc167411d9898f456cb5ef288 (patch)
tree2dc666e288e65259fa29fc74cb3da760390f8a4a /gcc
parent0aaf6c85d2f60bc9483e3834a1e1031b5d89c557 (diff)
downloadgcc-2af6a433d9630f5fc167411d9898f456cb5ef288.zip
gcc-2af6a433d9630f5fc167411d9898f456cb5ef288.tar.gz
gcc-2af6a433d9630f5fc167411d9898f456cb5ef288.tar.bz2
(duplicate_decls): Always warn when const declaration follows
non-const one for variables. From-SVN: r7076
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-decl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index a7cd30e..8aa0859 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -1593,10 +1593,16 @@ duplicate_decls (newdecl, olddecl)
&& !TREE_PUBLIC (newdecl))
warning_with_decl (newdecl, "static declaration for `%s' follows non-static");
+ /* Warn when const declaration follows a non-const
+ declaration, but not for functions. */
+ if (TREE_CODE (olddecl) != FUNCTION_DECL
+ && !TREE_READONLY (olddecl)
+ && TREE_READONLY (newdecl))
+ warning_with_decl (newdecl, "const declaration for `%s' follows non-const");
/* These bits are logically part of the type, for variables.
But not for functions
(where qualifiers are not valid ANSI anyway). */
- if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL
+ else if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL
&& (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
|| TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)))
pedwarn_with_decl (newdecl, "type qualifiers for `%s' conflict with previous decl");