aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-06-27 05:59:59 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-06-27 05:59:59 +0000
commit5d39dee0cca8d675120791234cd39a622b986f1b (patch)
tree398a33005d82f78a3c64066112616ed351b16c90
parent8f031b3b14e726b093fb8693c2be4ab6d779e331 (diff)
Fix a bogus error overloading an operator where the only class
parameter has a dependent type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74380 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp5
-rw-r--r--test/SemaTemplate/operator-template.cpp14
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index b7a429991f..cf0dab5cf2 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1789,7 +1789,7 @@ Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,
AttributeList *AttrList,
bool IsTypeName) {
assert(!SS.isInvalid() && "Invalid CXXScopeSpec.");
- assert(TargetName || Op && "Invalid TargetName.");
+ assert((TargetName || Op) && "Invalid TargetName.");
assert(IdentLoc.isValid() && "Invalid TargetName location.");
assert(S->getFlags() & Scope::DeclScope && "Invalid Scope.");
@@ -2746,7 +2746,8 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
ParamEnd = FnDecl->param_end();
Param != ParamEnd; ++Param) {
QualType ParamType = (*Param)->getType().getNonReferenceType();
- if (ParamType->isRecordType() || ParamType->isEnumeralType()) {
+ if (ParamType->isDependentType() || ParamType->isRecordType() ||
+ ParamType->isEnumeralType()) {
ClassOrEnumParam = true;
break;
}
diff --git a/test/SemaTemplate/operator-template.cpp b/test/SemaTemplate/operator-template.cpp
new file mode 100644
index 0000000000..3d041ec13a
--- /dev/null
+++ b/test/SemaTemplate/operator-template.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Make sure we accept this
+template<class X>struct A{typedef X Y;};
+template<class X>bool operator==(A<X>,typename A<X>::Y);
+int a(A<int> x) { return operator==(x,1); }
+
+// FIXME: The diagnostic here is a bit messed up
+template<class X>struct B{typedef X Y;};
+template<class X>bool operator==(B<X>*,typename B<X>::Y); // \
+expected-error{{overloaded 'operator==' must have at least one parameter of class or enumeration type}} \
+expected-note{{in instantiation of default argument for 'operator==<int>' required here}}
+int a(B<int> x) { return operator==(&x,1); }
+