diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-15 16:10:22 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-15 16:10:22 +0000 |
commit | 3c7a63e3227646d2e0412f16701694ef8907b602 (patch) | |
tree | ebc82354262263db18dd487af08e8f0384b840bb /gcc/cp/name-lookup.c | |
parent | 830b796a141c3fd1da7954dc955d2d63f6fc1ea7 (diff) | |
download | gcc-3c7a63e3227646d2e0412f16701694ef8907b602.tar.gz |
/cp
2013-05-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31952
* name-lookup.c (pushdecl_maybe_friend_1): Diagnose illegal
redeclarations.
/testsuite
2013-05-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31952
* g++.dg/parse/pr31952-1.C: New.
* g++.dg/parse/pr31952-2.C: Likewise.
* g++.dg/parse/pr31952-3.C: Likewise.
* g++.dg/parse/pr18770.C: Adjust dg-errors to dg-messages.
* g++.old-deja/g++.jason/cond.C: Likewise.
* g++.dg/cpp0x/range-for5.C: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198939 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r-- | gcc/cp/name-lookup.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index e09eca174b6..a60504fafdf 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1131,7 +1131,32 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) || oldscope->kind == sk_for)) { error ("redeclaration of %q#D", x); - error ("%q+#D previously declared here", oldlocal); + inform (input_location, "%q+#D previously declared here", + oldlocal); + nowarn = true; + } + /* C++11: + 3.3.3/3: The name declared in an exception-declaration (...) + shall not be redeclared in the outermost block of the handler. + 3.3.3/2: A parameter name shall not be redeclared (...) in + the outermost block of any handler associated with a + function-try-block. + 3.4.1/15: The function parameter names shall not be redeclared + in the exception-declaration nor in the outermost block of a + handler for the function-try-block. */ + else if ((VAR_P (oldlocal) + && oldscope == current_binding_level->level_chain + && oldscope->kind == sk_catch) + || (TREE_CODE (oldlocal) == PARM_DECL + && (current_binding_level->kind == sk_catch + || (current_binding_level->level_chain->kind + == sk_catch)) + && in_function_try_handler)) + { + if (permerror (input_location, "redeclaration of %q#D", x)) + inform (input_location, "%q+#D previously declared here", + oldlocal); + nowarn = true; } if (warn_shadow && !nowarn) |