r177003 applied the late parsed template technique to friend functions but omitted the corresponding check for redefinitions.
This patch adds the same check already in use for templates to the new code path in order to diagnose and reject invalid redefinitions that were being silently accepted. Fixes PR17324. -- http://www.nuanti.com the browser experts
commit 360a30d0eb91223da4fbad92de3cb8c67ea1254f Author: Alp Toker <[email protected]> Date: Sun Sep 22 23:10:59 2013 +0100 Check "late parsed" friend functions for redefinition r177003 applied the late parsed template technique to friend functions but omitted the corresponding check for redefinitions. This patch adds the same check already in use for templates to the new code path in order to diagnose and reject invalid redefinitions that were being silently accepted. Fixes PR17324. diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index 8d82d03..6bab798 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -176,7 +176,9 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, // If you remove this, you can remove the code that clears the flag // after parsing the member. if (D.getDeclSpec().isFriendSpecified()) { - getFunctionDecl(FnD)->setLateTemplateParsed(true); + FunctionDecl *FD = getFunctionDecl(FnD); + Actions.CheckForFunctionRedefinition(FD); + FD->setLateTemplateParsed(true); } } else { // If semantic analysis could not build a function declaration, diff --git a/test/SemaCXX/linkage2.cpp b/test/SemaCXX/linkage2.cpp index dde239f..f759142 100644 --- a/test/SemaCXX/linkage2.cpp +++ b/test/SemaCXX/linkage2.cpp @@ -166,6 +166,15 @@ namespace test16 { } } +namespace test16a { + extern "C" { + void bar2() {} // expected-note {{previous definition is here}} + class Foo2 { + friend void bar2() {} // expected-error {{redefinition of 'bar2'}} + }; + } +} + namespace test17 { namespace { struct I {
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
