From dde85a8d603a9cc34896c002be2340ebae61407f Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sat, 20 Aug 2016 14:50:22 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279371 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExceptionSpec.cpp | 3 ++- test/SemaCXX/libstdcxx_pair_swap_hack.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 4a21eb308f..73b39cc550 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -44,7 +44,8 @@ bool Sema::isLibstdcxxEagerExceptionSpecHack(const Declarator &D) { // 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; diff --git a/test/SemaCXX/libstdcxx_pair_swap_hack.cpp b/test/SemaCXX/libstdcxx_pair_swap_hack.cpp index 02431e02e4..6d783fe503 100644 --- a/test/SemaCXX/libstdcxx_pair_swap_hack.cpp +++ b/test/SemaCXX/libstdcxx_pair_swap_hack.cpp @@ -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 void swap(T &, T &); template void do_swap(T &a, T &b) noexcept(noexcept(swap(a, b))) { -- 2.50.1