[PATCH] PR17324 - Check "late parsed" friend functions for redefinition
Alp Toker
alp at nuanti.com
Tue Sep 24 03:29:58 PDT 2013
Update with a simpler test case attached.
On 24/09/2013 11:00, Alp Toker wrote:
> 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.
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
--
http://www.nuanti.com
the browser experts
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130924/7c73bc29/attachment.html>
-------------- next part --------------
commit 844f24884204d7c7d93df35143a4bbefbdd89384
Author: Alp Toker <alp at nuanti.com>
Date: Tue Sep 24 11:26:46 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/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp
index a13e7ba..a3b89cc 100644
--- a/test/Parser/cxx-friend.cpp
+++ b/test/Parser/cxx-friend.cpp
@@ -30,6 +30,10 @@ class B {
void f(A *a) { a->f(); }
};
+void bar() {} // expected-note {{previous definition is here}}
+class E {
+ friend void bar() {} // expected-error {{redefinition of 'bar'}}
+};
More information about the cfe-commits
mailing list