diff options
| author | Kaelyn Takata <rikka@google.com> | 2015-09-30 18:23:35 +0000 |
|---|---|---|
| committer | Kaelyn Takata <rikka@google.com> | 2015-09-30 18:23:35 +0000 |
| commit | d14c06169cce96fae3cf9565b216286ef52765b6 (patch) | |
| tree | c3a6dbe3602e3cb9e9bbf25fe10b667d4d5d5b4d /clang | |
| parent | b0c6d9174ef6d1ce4eac5951dd42107b1a49ecfc (diff) | |
| download | bcm5719-llvm-d14c06169cce96fae3cf9565b216286ef52765b6.tar.gz bcm5719-llvm-d14c06169cce96fae3cf9565b216286ef52765b6.zip | |
Don't correct non-class using declarations to class members.
Such declarations would be invalid anyway, and trying to make the
correction will lead to a crash. Fixes PR 24781.
llvm-svn: 248928
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/typo-correction.cpp | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index ff9c93d2f69..07bf8567194 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -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)) diff --git a/clang/test/SemaCXX/typo-correction.cpp b/clang/test/SemaCXX/typo-correction.cpp index 174b1403e2d..d5b42d0e537 100644 --- a/clang/test/SemaCXX/typo-correction.cpp +++ b/clang/test/SemaCXX/typo-correction.cpp @@ -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'?}} +} |

