]> granicus.if.org Git - clang/commitdiff
Don't correct non-class using declarations to class members.
authorKaelyn Takata <rikka@google.com>
Wed, 30 Sep 2015 18:23:35 +0000 (18:23 +0000)
committerKaelyn Takata <rikka@google.com>
Wed, 30 Sep 2015 18:23:35 +0000 (18:23 +0000)
Such declarations would be invalid anyway, and trying to make the
correction will lead to a crash. Fixes PR 24781.

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

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/typo-correction.cpp

index ff9c93d2f6964a4ca435cbc15dbba46cdbc2aafc..07bf856719406adfcef9c4304126b71ca8f1c448 100644 (file)
@@ -8031,6 +8031,10 @@ public:
 
         // FIXME: Check that the base class member is accessible?
       }
+    } else {
+      auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
+      if (FoundRecord && FoundRecord->isInjectedClassName())
+        return false;
     }
 
     if (isa<TypeDecl>(ND))
index 174b1403e2dbc5015b04774c6634b603f691a3c7..d5b42d0e537949bf0a35838b3fa9df01bfc998ff 100644 (file)
@@ -640,3 +640,19 @@ int has_include(int); // expected-note {{'has_include' declared here}}
 // expected-error@+1 {{__has_include must be used within a preprocessing directive}}
 int foo = __has_include(42); // expected-error {{use of undeclared identifier '__has_include'; did you mean 'has_include'?}}
 }
+
+namespace PR24781_using_crash {
+namespace A {
+namespace B {
+class Foofoo {};  // expected-note {{'A::B::Foofoo' declared here}}
+}
+}
+
+namespace C {
+namespace D {
+class Bar : public A::B::Foofoo {};
+}
+}
+
+using C::D::Foofoo;  // expected-error {{no member named 'Foofoo' in namespace 'PR24781_using_crash::C::D'; did you mean 'A::B::Foofoo'?}}
+}