diff options
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) |