r192948 - Check "late parsed" friend functions for redefinition
Alp Toker
alp at nuanti.com
Thu Oct 17 22:54:24 PDT 2013
Author: alp
Date: Fri Oct 18 00:54:24 2013
New Revision: 192948
URL: http://llvm.org/viewvc/llvm-project?rev=192948&view=rev
Log:
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.
Reviewed by Richard Smith.
Modified:
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/test/Parser/cxx-friend.cpp
Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=192948&r1=192947&r2=192948&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Fri Oct 18 00:54:24 2013
@@ -176,7 +176,9 @@ NamedDecl *Parser::ParseCXXInlineMethodD
// 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,
Modified: cfe/trunk/test/Parser/cxx-friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-friend.cpp?rev=192948&r1=192947&r2=192948&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-friend.cpp (original)
+++ cfe/trunk/test/Parser/cxx-friend.cpp Fri Oct 18 00:54:24 2013
@@ -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