]> granicus.if.org Git - clang/commitdiff
Fix the crash-on-invalid from PR6259.
authorJohn McCall <rjmccall@apple.com>
Mon, 8 Feb 2010 19:26:07 +0000 (19:26 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 8 Feb 2010 19:26:07 +0000 (19:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95554 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/nested-name-spec.cpp

index 4e448d81976ca053c362aca17ea04ade0751e34e..abb4e786d6c41fdc642960148006bfe44be9f1b2 100644 (file)
@@ -700,7 +700,13 @@ static void DecomposeTemplateName(LookupResult &R, const UnqualifiedId &Id) {
   R.resolveKind();
 }
 
+/// Determines whether the given record is "fully-formed" at the given
+/// location, i.e. whether a qualified lookup into it is assured of
+/// getting consistent results already.
 static bool IsFullyFormedScope(Sema &SemaRef, CXXRecordDecl *Record) {
+  if (!Record->hasDefinition())
+    return false;
+
   for (CXXRecordDecl::base_class_iterator I = Record->bases_begin(),
          E = Record->bases_end(); I != E; ++I) {
     CanQualType BaseT = SemaRef.Context.getCanonicalType((*I).getType());
@@ -708,7 +714,7 @@ static bool IsFullyFormedScope(Sema &SemaRef, CXXRecordDecl *Record) {
     if (!BaseRT) return false;
 
     CXXRecordDecl *BaseRecord = cast<CXXRecordDecl>(BaseRT->getDecl());
-    if (!BaseRecord->isDefinition() ||
+    if (!BaseRecord->hasDefinition() ||
         !IsFullyFormedScope(SemaRef, BaseRecord))
       return false;
   }
index dbbf1fecc9f3cf32b1f55561a89a7f141b168dff..8a217b312088682601571f96a313b7aed650a407 100644 (file)
@@ -220,3 +220,12 @@ namespace test2 {
 
   int *ns::count_ptr = &count;
 }
+
+// PR6259, invalid case
+namespace test3 {
+  // FIXME: this should really only trigger once
+  class A; // expected-note 2 {{forward declaration}}
+  void foo(const char *path) {
+    A::execute(path); // expected-error 2 {{incomplete type 'class test3::A' named in nested name specifier}}
+  }
+}