diff options
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 20 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/dependent-names.cpp | 14 | 
2 files changed, 23 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index e5a3deebc2f..47c433192c3 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -9536,18 +9536,16 @@ DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc,        SemaRef.FindAssociatedClassesAndNamespaces(FnLoc, Args,                                                   AssociatedNamespaces,                                                   AssociatedClasses); -      // Never suggest declaring a function within namespace 'std'.  +      // Never suggest declaring a function within namespace 'std'.        Sema::AssociatedNamespaceSet SuggestedNamespaces; -      if (DeclContext *Std = SemaRef.getStdNamespace()) { -        for (Sema::AssociatedNamespaceSet::iterator -               it = AssociatedNamespaces.begin(), -               end = AssociatedNamespaces.end(); it != end; ++it) { -          if (!Std->Encloses(*it)) -            SuggestedNamespaces.insert(*it); -        } -      } else { -        // Lacking the 'std::' namespace, use all of the associated namespaces. -        SuggestedNamespaces = AssociatedNamespaces; +      DeclContext *Std = SemaRef.getStdNamespace(); +      for (Sema::AssociatedNamespaceSet::iterator +             it = AssociatedNamespaces.begin(), +             end = AssociatedNamespaces.end(); it != end; ++it) { +        NamespaceDecl *Assoc = cast<NamespaceDecl>(*it); +        if ((!Std || !Std->Encloses(Assoc)) && +            Assoc->getQualifiedNameAsString().find("__") == std::string::npos) +          SuggestedNamespaces.insert(Assoc);        }        SemaRef.Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup) diff --git a/clang/test/SemaTemplate/dependent-names.cpp b/clang/test/SemaTemplate/dependent-names.cpp index efa4d28723d..7ef12b8788b 100644 --- a/clang/test/SemaTemplate/dependent-names.cpp +++ b/clang/test/SemaTemplate/dependent-names.cpp @@ -346,3 +346,17 @@ namespace rdar12629723 {      virtual void foo() { }    };  } + +namespace test_reserved_identifiers { +  template<typename A, typename B> void tempf(A a, B b) { +    a + b;  // expected-error{{call to function 'operator+' that is neither visible in the template definition nor found by argument-dependent lookup}} +  } +  namespace __gnu_cxx { struct X {}; } +  namespace ns { struct Y {}; } +  void operator+(__gnu_cxx::X, ns::Y);  // expected-note{{or in namespace 'test_reserved_identifiers::ns'}} +  void test() { +    __gnu_cxx::X x; +    ns::Y y; +    tempf(x, y);  // expected-note{{in instantiation of}} +  } +}  | 

