summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-12-17 04:29:27 +0000
committerBill Wendling <isanbard@gmail.com>2013-12-17 04:29:27 +0000
commit9a5d6bb0c26215adddc5ce00f21d863160cbd0b7 (patch)
tree6e69de7027d694c230e33835059ecf4ff0f06b38
parent4b9339d9e359b35f15535a3fd174c2f1fee3810a (diff)
downloadclang-9a5d6bb0c26215adddc5ce00f21d863160cbd0b7.tar.gz
clang-9a5d6bb0c26215adddc5ce00f21d863160cbd0b7.tar.bz2
clang-9a5d6bb0c26215adddc5ce00f21d863160cbd0b7.tar.xz
Merging r197409:
------------------------------------------------------------------------ r197409 | rikka | 2013-12-16 11:19:18 -0800 (Mon, 16 Dec 2013) | 4 lines Make Sema::BuildCXXNestedNameSpecifier correctly clear the previous 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/branches/release_34@197463 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaCXXScopeSpec.cpp2
-rw-r--r--test/SemaCXX/typo-correction-pt2.cpp18
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp
index 674411ec06..554a114bae 100644
--- a/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/lib/Sema/SemaCXXScopeSpec.cpp
@@ -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());
diff --git a/test/SemaCXX/typo-correction-pt2.cpp b/test/SemaCXX/typo-correction-pt2.cpp
index 2da52b31f5..525d11b0a6 100644
--- a/test/SemaCXX/typo-correction-pt2.cpp
+++ b/test/SemaCXX/typo-correction-pt2.cpp
@@ -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}}
+}