: WantTypeSpecifiers(true), WantExpressionKeywords(true),
WantCXXNamedCasts(true), WantRemainingKeywords(true),
WantObjCSuper(false),
- IsObjCIvarLookup(false) {}
+ IsObjCIvarLookup(false), AllowAddedQualifier(true) {}
virtual ~CorrectionCandidateCallback() {}
// Temporary hack for the one case where a CorrectTypoContext enum is used
// when looking up results.
bool IsObjCIvarLookup;
+
+ /// \brief Whether to allow this typo correction to add a
+ /// nested-name-specifier.
+ bool AllowAddedQualifier;
};
/// @brief Simple template class for restricting typo correction candidates
class DifferentNameValidatorCCC : public CorrectionCandidateCallback {
public:
DifferentNameValidatorCCC(CXXRecordDecl *Parent)
- : ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {}
+ : ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {
+ // Don't allow any additional qualification.
+ // FIXME: It would be nice to perform this additional qualification.
+ // However, DiagnoseInvalidRedeclaration is unable to handle the
+ // qualification, because it doesn't know how to pass the corrected
+ // nested-name-specifier through to ActOnFunctionDeclarator.
+ AllowAddedQualifier = false;
+ }
virtual bool ValidateCandidate(const TypoCorrection &candidate) {
if (candidate.getEditDistance() == 0)
}
}
- if (IsUnqualifiedLookup || (QualifiedDC && QualifiedDC->isNamespace())) {
+ // Determine whether we are going to search in the various namespaces for
+ // corrections.
+ bool SearchNamespaces
+ = getLangOpts().CPlusPlus && CCC.AllowAddedQualifier &&
+ (IsUnqualifiedLookup || (QualifiedDC && QualifiedDC->isNamespace()));
+
+ if (IsUnqualifiedLookup || SearchNamespaces) {
// For unqualified lookup, look through all of the names that we have
// seen in this translation unit.
// FIXME: Re-add the ability to skip very unlikely potential corrections.
return TypoCorrection();
}
- // Build the NestedNameSpecifiers for the KnownNamespaces
- if (getLangOpts().CPlusPlus) {
+ // Build the NestedNameSpecifiers for the KnownNamespaces, if we're going
+ // to search those namespaces.
+ if (SearchNamespaces) {
// Load any externally-known namespaces.
if (ExternalSource && !LoadedExternalKnownNamespaces) {
SmallVector<NamespaceDecl *, 4> ExternalKnownNamespaces;
break;
// Only perform the qualified lookups for C++
- if (getLangOpts().CPlusPlus) {
+ if (SearchNamespaces) {
TmpRes.suppressDiagnostics();
for (llvm::SmallVector<TypoCorrection,
16>::iterator QRI = QualifiedResults.begin(),
// expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} \
// expected-error {{use of undeclared identifier 't'}}
}
+
+// FIXME: It would be nice if we could get this correction right.
+namespace PR12297 {
+ namespace A {
+ typedef short T;
+
+ namespace B {
+ typedef short T;
+
+ T global();
+ }
+ }
+
+ using namespace A::B;
+
+ T A::global(); // expected-error{{out-of-line definition of 'global' does not match any declaration in namespace 'PR12297::A'}}
+}