diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-05 23:20:00 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-05 23:20:00 +0000 |
commit | 5f3cead1c3b996f3befc42f99c6eca142fdb0550 (patch) | |
tree | e2ef9f427adfe62b09b758c20b2ffdb1802526ba /gcc/testsuite/gcc.dg/Wshadow-1.c | |
parent | f54f869d4b3eed4a54f73b7e796da0b971dacc81 (diff) | |
download | gcc-5f3cead1c3b996f3befc42f99c6eca142fdb0550.tar.gz |
* c-common.c (shadow_warning): New function, moved from cp/decl.c.
* c-common.h (shadow_warning): New.
* c-decl.c: Include c-common.h.
(warn_if_shadowing): New, broken out of pushdecl.
(pushdecl): Use warn_if_shadowing.
(store_parm_decls): Prevent duplicate -Wshadow warnings.
cp:
* decl.c: Include c-common.h.
(shadow_warning): Move to c-common.c.
testsuite:
* gcc.dg/Wshadow-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47701 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wshadow-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wshadow-1.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wshadow-1.c b/gcc/testsuite/gcc.dg/Wshadow-1.c new file mode 100644 index 00000000000..63808aa9c89 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wshadow-1.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-Wshadow -pedantic-errors" } */ + +/* Source: Neil Booth, 5 Dec 2001. */ + +int decl1; /* { dg-warning "shadowed declaration" } */ +void foo (double decl1) /* { dg-warning "shadows a global decl" } */ +{ +} + +void foo1 (int d) +{ + double d; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "shadows a parameter" "" { target *-*-* } 15 } */ +} + +void foo2 (int d) /* { dg-warning "shadowed declaration" } */ +{ + { + double d; /* { dg-warning "shadows a parameter" } */ + } +} + +void foo3 () +{ + int local; /* { dg-warning "shadowed declaration" } */ + { + int local; /* { dg-warning "shadows a previous local" } */ + } +} |