From 5d39dee0cca8d675120791234cd39a622b986f1b Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 27 Jun 2009 05:59:59 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaDeclCXX.cpp | 5 +++-- test/SemaTemplate/operator-template.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/SemaTemplate/operator-template.cpp 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 +templatestruct A{typedef X Y;}; +templatebool operator==(A,typename A::Y); +int a(A x) { return operator==(x,1); } + +// FIXME: The diagnostic here is a bit messed up +templatestruct B{typedef X Y;}; +templatebool operator==(B*,typename B::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==' required here}} +int a(B x) { return operator==(&x,1); } + -- 2.40.0