[cfe-commits] r74380 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaTemplate/operator-template.cpp

Eli Friedman eli.friedman at gmail.com
Fri Jun 26 22:59:59 PDT 2009


Author: efriedma
Date: Sat Jun 27 00:59:59 2009
New Revision: 74380

URL: http://llvm.org/viewvc/llvm-project?rev=74380&view=rev
Log:
Fix a bogus error overloading an operator where the only class 
parameter has a dependent type.


Added:
    cfe/trunk/test/SemaTemplate/operator-template.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=74380&r1=74379&r2=74380&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Jun 27 00:59:59 2009
@@ -1789,7 +1789,7 @@
                                           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 @@
                                    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;
       }

Added: cfe/trunk/test/SemaTemplate/operator-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/operator-template.cpp?rev=74380&view=auto

==============================================================================
--- cfe/trunk/test/SemaTemplate/operator-template.cpp (added)
+++ cfe/trunk/test/SemaTemplate/operator-template.cpp Sat Jun 27 00:59:59 2009
@@ -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); }
+





More information about the cfe-commits mailing list