From 3c7a63e3227646d2e0412f16701694ef8907b602 Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 15 May 2013 16:10:22 +0000 Subject: /cp 2013-05-15 Paolo Carlini PR c++/31952 * name-lookup.c (pushdecl_maybe_friend_1): Diagnose illegal redeclarations. /testsuite 2013-05-15 Paolo Carlini 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 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/name-lookup.c | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index aea304b960e..cf91769b72f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-15 Paolo Carlini + + PR c++/31952 + * name-lookup.c (pushdecl_maybe_friend_1): Diagnose illegal + redeclarations. + 2013-05-14 Jason Merrill PR c++/57243 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) -- cgit v1.2.1