Author: vvassilev Date: Sat Aug 20 09:50:22 2016 New Revision: 279371 URL: http://llvm.org/viewvc/llvm-project?rev=279371&view=rev Log: PR28423: Compare primary declaration contexts.
In certain cases (mostly coming from modules), Sema's idea of the StdNamespace does not point to the first declaration of namespace std. Patch by Cristina Cristescu! Reviewed by Richard Smith. Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp cfe/trunk/test/SemaCXX/libstdcxx_pair_swap_hack.cpp Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=279371&r1=279370&r2=279371&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original) +++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Sat Aug 20 09:50:22 2016 @@ -44,7 +44,8 @@ bool Sema::isLibstdcxxEagerExceptionSpec // All the problem cases are member functions named "swap" within class // templates declared directly within namespace std. - if (!RD || RD->getEnclosingNamespaceContext() != getStdNamespace() || + if (!RD || !getStdNamespace() || + !RD->getEnclosingNamespaceContext()->Equals(getStdNamespace()) || !RD->getIdentifier() || !RD->getDescribedClassTemplate() || !D.getIdentifier() || !D.getIdentifier()->isStr("swap")) return false; Modified: cfe/trunk/test/SemaCXX/libstdcxx_pair_swap_hack.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/libstdcxx_pair_swap_hack.cpp?rev=279371&r1=279370&r2=279371&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/libstdcxx_pair_swap_hack.cpp (original) +++ cfe/trunk/test/SemaCXX/libstdcxx_pair_swap_hack.cpp Sat Aug 20 09:50:22 2016 @@ -8,6 +8,7 @@ // affected are array, pair, priority_queue, stack, and queue. // RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=array +// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=array -DPR28423 // RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=pair // RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=priority_queue // RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=stack @@ -21,6 +22,10 @@ #ifdef BE_THE_HEADER #pragma GCC system_header +#ifdef PR28423 +using namespace std; +#endif + namespace std { template<typename T> void swap(T &, T &); template<typename T> void do_swap(T &a, T &b) noexcept(noexcept(swap(a, b))) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits