summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-10-18 05:54:24 +0000
committerAlp Toker <alp@nuanti.com>2013-10-18 05:54:24 +0000
commit19bff32e093de869aaf7fe2161ed23718d62e437 (patch)
tree2785af7be0cafa7d7d13ba63bb9f6c6fca599eb5
parentae3a944a6e35dc94f553fb11b749f8e042a6d721 (diff)
downloadbcm5719-llvm-19bff32e093de869aaf7fe2161ed23718d62e437.tar.gz
bcm5719-llvm-19bff32e093de869aaf7fe2161ed23718d62e437.zip
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. llvm-svn: 192948
-rw-r--r--clang/lib/Parse/ParseCXXInlineMethods.cpp4
-rw-r--r--clang/test/Parser/cxx-friend.cpp4
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp
index 8d82d03d830..6bab7988cf0 100644
--- a/clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/clang/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/clang/test/Parser/cxx-friend.cpp b/clang/test/Parser/cxx-friend.cpp
index a13e7babc53..a3b89cc688b 100644
--- a/clang/test/Parser/cxx-friend.cpp
+++ b/clang/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'}}
+};
OpenPOWER on IntegriCloud