]> granicus.if.org Git - clang/commitdiff
Fix a bogus error overloading an operator where the only class
authorEli Friedman <eli.friedman@gmail.com>
Sat, 27 Jun 2009 05:59:59 +0000 (05:59 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 27 Jun 2009 05:59:59 +0000 (05:59 +0000)
parameter has a dependent type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74380 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaTemplate/operator-template.cpp [new file with mode: 0644]

index b7a429991f4345b127f4040031d0d82f57d6909d..cf0dab5cf298aaa0a88f1fd15e12990058be0c0a 100644 (file)
@@ -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 (file)
index 0000000..3d041ec
--- /dev/null
@@ -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); }
+