From: Douglas Gregor Date: Thu, 7 Jan 2010 00:26:25 +0000 (+0000) Subject: When we typo-correct a base class initializer, point to the base class X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d535c89c5d02017153fb971e1ef080cd80cb4b8;p=clang When we typo-correct a base class initializer, point to the base class specifier that we corrected to. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92878 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 9d5ef0b402..710e977261 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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">; } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 7ae0440b40..d3c8de326c 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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; } } diff --git a/test/FixIt/typo.cpp b/test/FixIt/typo.cpp index ffeb18dde1..50c6d312b8 100644 --- a/test/FixIt/typo.cpp +++ b/test/FixIt/typo.cpp @@ -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'?}}