]> granicus.if.org Git - clang/commitdiff
When we typo-correct a base class initializer, point to the base class
authorDouglas Gregor <dgregor@apple.com>
Thu, 7 Jan 2010 00:26:25 +0000 (00:26 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 7 Jan 2010 00:26:25 +0000 (00:26 +0000)
specifier that we corrected to.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclCXX.cpp
test/FixIt/typo.cpp

index 9d5ef0b40278f048dc4ca050d5d01ac26cf03bf7..710e97726110e398cd4b955d94a5409100ef7ada 100644 (file)
@@ -2594,7 +2594,8 @@ def err_undef_superclass_suggest : Error<
   "%2?">;
 def err_undeclared_protocol_suggest : Error<
   "cannot find protocol declaration for %0; did you mean %1?">;
-
+def note_base_class_specified_here : Note<
+  "base class %0 specified here">;
 }
 
 
index 7ae0440b409d9ccc8d12eeecfd312a18b54d624a..d3c8de326c0bc89e2463c1eae19b566fea3e7dee 100644 (file)
@@ -1091,7 +1091,14 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
               << MemberOrBase << false << R.getLookupName()
               << CodeModificationHint::CreateReplacement(R.getNameLoc(),
                                                R.getLookupName().getAsString());
-            
+
+            const CXXBaseSpecifier *BaseSpec = DirectBaseSpec? DirectBaseSpec 
+                                                             : VirtualBaseSpec;
+            Diag(BaseSpec->getSourceRange().getBegin(),
+                 diag::note_base_class_specified_here)
+              << BaseSpec->getType()
+              << BaseSpec->getSourceRange();
+
             TyD = Type;
           }
         }
index ffeb18dde103e952b4bf0ef858448e7f01a62390..50c6d312b8c2425afeb00920e646f6fd8427658a 100644 (file)
@@ -35,7 +35,7 @@ bool test_string(std::string s) {
 }
 
 struct Base { };
-struct Derived : public Base {
+struct Derived : public Base { // expected-note{{base class 'struct Base' specified here}}
   int member; // expected-note 3{{'member' declared here}}
 
   Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}