aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-24 17:31:23 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-24 17:31:23 +0000
commit036ada215d2c53e6a286b42d7cbd2386b0007516 (patch)
tree1e87ac7637865334fa29c5985295f8f15cd7f6c6
parent9ff659b1950fa67958a057b97fdd36aadfb8017e (diff)
Silently drop dependent friend function template specializations,
since we have absolutely no way to match them when they are declared nor do we have a way to represent these parsed-but-not-checked friend declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99407 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp15
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p1.cpp12
2 files changed, 22 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index e802018c9f..e4c930e2f8 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3130,10 +3130,17 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
}
if (isFunctionTemplateSpecialization) {
- if (CheckFunctionTemplateSpecialization(NewFD,
- (HasExplicitTemplateArgs ? &TemplateArgs : 0),
- Previous))
- NewFD->setInvalidDecl();
+ if (isFriend && NewFD->getType()->isDependentType()) {
+ // FIXME: When we see a friend of a function template
+ // specialization with a dependent type, we can't match it now;
+ // for now, we just drop it, until we have a reasonable way to
+ // represent the parsed-but-not-matched friend function template
+ // specialization in the AST.
+ return 0;
+ } else if (CheckFunctionTemplateSpecialization(NewFD,
+ (HasExplicitTemplateArgs ? &TemplateArgs : 0),
+ Previous))
+ NewFD->setInvalidDecl();
} else if (isExplicitSpecialization && isa<CXXMethodDecl>(NewFD) &&
CheckMemberSpecialization(NewFD, Previous))
NewFD->setInvalidDecl();
diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
index 0f18e76f52..277106c2bd 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -faccess-control -verify -emit-llvm-only %s
-
template <typename T> struct Num {
T value_;
@@ -117,3 +116,14 @@ namespace test3 {
template class User<int>; // expected-note {{requested here}}
}
+
+namespace Dependent {
+ template<typename T, typename Traits> class X;
+ template<typename T, typename Traits>
+ X<T, Traits> operator+(const X<T, Traits>&, const T*);
+
+ template<typename T, typename Traits> class X {
+ typedef typename Traits::value_type value_type;
+ friend X operator+<>(const X&, const value_type*);
+ };
+}