[cfe-commits] r89180 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/arrow-operator.cpp

Eli Friedman eli.friedman at gmail.com
Tue Nov 17 17:28:03 PST 2009


Author: efriedma
Date: Tue Nov 17 19:28:03 2009
New Revision: 89180

URL: http://llvm.org/viewvc/llvm-project?rev=89180&view=rev
Log:
PR5520: Make sure to check whether the base type is complete before looking for
operator->.


Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/arrow-operator.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Nov 17 19:28:03 2009
@@ -5503,6 +5503,11 @@
   OverloadCandidateSet CandidateSet;
   const RecordType *BaseRecord = Base->getType()->getAs<RecordType>();
 
+  if (RequireCompleteType(Base->getLocStart(), Base->getType(),
+                          PDiag(diag::err_typecheck_incomplete_tag)
+                            << Base->getSourceRange()))
+    return ExprError();
+
   LookupResult R(*this, OpName, OpLoc, LookupOrdinaryName);
   LookupQualifiedName(R, BaseRecord->getDecl());
   R.suppressDiagnostics();

Modified: cfe/trunk/test/SemaCXX/arrow-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/arrow-operator.cpp?rev=89180&r1=89179&r2=89180&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/arrow-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/arrow-operator.cpp Tue Nov 17 19:28:03 2009
@@ -16,7 +16,10 @@
 
 struct D : A { };
 
-void f(C &c, D& d) {
+struct E; // expected-note {{forward declaration of 'struct E'}}
+
+void f(C &c, D& d, E& e) {
   c->f(); // expected-error{{use of overloaded operator '->' is ambiguous}}
   d->f();
+  e->f(); // expected-error{{incomplete definition of type}}
 }





More information about the cfe-commits mailing list