]> granicus.if.org Git - clang/commitdiff
Make Sema::BuildCXXNestedNameSpecifier correctly clear the previous
authorKaelyn Uhrain <rikka@google.com>
Mon, 16 Dec 2013 19:19:18 +0000 (19:19 +0000)
committerKaelyn Uhrain <rikka@google.com>
Mon, 16 Dec 2013 19:19:18 +0000 (19:19 +0000)
CXXScopeSpec when necessary while performing typo correction. This fixes
the crash reported in PR18213 (the problem existed since r185487, and
r193020 made it easier to hit).

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

lib/Sema/SemaCXXScopeSpec.cpp
test/SemaCXX/typo-correction-pt2.cpp

index 58bde02d602b710a2430c137480152d34d0a46ae..15f122ecb10908402d828b7ac074a0dd4563d987 100644 (file)
@@ -497,6 +497,8 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
         bool DroppedSpecifier =
             Corrected.WillReplaceSpecifier() &&
             Name.getAsString() == Corrected.getAsString(getLangOpts());
+        if (DroppedSpecifier)
+          SS.clear();
         diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
                                   << Name << LookupCtx << DroppedSpecifier
                                   << SS.getRange());
index bb5e8f8c934bb4f14f66525cab00cd0f56042a28..789510049011ab043f2f5f6686f70a65803e5613 100644 (file)
@@ -181,3 +181,21 @@ void test() {
   MessageHeaders::ParseMessageHeaders(5, 4); // expected-error {{no member named 'ParseMessageHeaders' in 'fix_class_name_qualifier::MessageHeaders'; did you mean 'MessageUtils::ParseMessageHeaders'?}}
 }
 }
+
+namespace PR18213 {  // expected-note {{'PR18213' declared here}}
+struct WrapperInfo {
+  int i;
+};
+
+template <typename T> struct Wrappable {
+  static WrapperInfo kWrapperInfo;
+};
+
+// Note the space before "::PR18213" is intended and needed, as it highlights
+// the actual typo, which is the leading "::".
+// TODO: Suggest removing the "::" from "::PR18213" (the right correction)
+// instead of incorrectly suggesting dropping "PR18213::WrapperInfo::".
+template <>
+PR18213::WrapperInfo ::PR18213::Wrappable<int>::kWrapperInfo = { 0 };  // expected-error {{no member named 'PR18213' in 'PR18213::WrapperInfo'; did you mean simply 'PR18213'?}} \
+                                                                       // expected-error {{C++ requires a type specifier for all declarations}}
+}