]> granicus.if.org Git - clang/commitdiff
Don't consider records with a NULL identifier as a name for typo correction.
authorKaelyn Uhrain <rikka@google.com>
Wed, 5 Feb 2014 18:57:51 +0000 (18:57 +0000)
committerKaelyn Uhrain <rikka@google.com>
Wed, 5 Feb 2014 18:57:51 +0000 (18:57 +0000)
Because in C++, "anonymous" doesn't mean "nameless" for records. In
other words, RecordDecl::isAnonymousStructOrUnion only returns true if
the record lacks a name *and* is not used as the type in an object's
declaration.

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

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

index 39dd555aeae726c7a58fc9aba270a8ebe6ff2e51..8a5c0a5ba7eb28c9bd10079d1ce85fe8f24b0cf0 100644 (file)
@@ -4216,7 +4216,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
       if (CXXRecordDecl *CD = (*TI)->getAsCXXRecordDecl()) {
         CD = CD->getCanonicalDecl();
         if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
-            !CD->isUnion() &&
+            !CD->isUnion() && CD->getIdentifier() &&
             (CD->isBeingDefined() || CD->isCompleteDefinition()))
           Namespaces.AddNameSpecifier(CD);
       }
index 789510049011ab043f2f5f6686f70a65803e5613..65d961085a8c7669129257fa9c5ae78e1b32f2c8 100644 (file)
@@ -199,3 +199,11 @@ 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}}
 }
+
+namespace PR18651 {
+struct {
+  int x;
+} a, b;
+
+int y = x;  // expected-error-re {{use of undeclared identifier 'x'{{$}}}}
+}