From 7d7dee753dc91b24fee3f39af37b2432e9fe41a2 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 24 Feb 2015 03:30:14 +0000 Subject: [PATCH] [modules] Properly check whether a declaration is std::initializer_list. This bug is not actually modules-specific, but it's a little tricky to tickle it outside of modules builds, so submitting with the reduced testcase I have. llvm-svn: 230303 --- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- .../{initializer_list => initializer_list/direct.h} | 0 .../Modules/Inputs/initializer_list/direct.modulemap | 1 + clang/test/Modules/Inputs/initializer_list/indirect.h | 1 + .../Modules/Inputs/initializer_list/indirect.modulemap | 1 + clang/test/Modules/Inputs/module.map | 4 ---- clang/test/Modules/initializer_list.cpp | 18 +++++++++++++++++- 7 files changed, 21 insertions(+), 6 deletions(-) rename clang/test/Modules/Inputs/{initializer_list => initializer_list/direct.h} (100%) create mode 100644 clang/test/Modules/Inputs/initializer_list/direct.modulemap create mode 100644 clang/test/Modules/Inputs/initializer_list/indirect.h create mode 100644 clang/test/Modules/Inputs/initializer_list/indirect.modulemap diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 39732a0..c41dc33 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -7373,7 +7373,7 @@ bool Sema::isStdInitializerList(QualType Ty, QualType *Element) { StdInitializerList = Template; } - if (Template != StdInitializerList) + if (Template->getCanonicalDecl() != StdInitializerList->getCanonicalDecl()) return false; // This is an instance of std::initializer_list. Find the argument type. diff --git a/clang/test/Modules/Inputs/initializer_list b/clang/test/Modules/Inputs/initializer_list/direct.h similarity index 100% rename from clang/test/Modules/Inputs/initializer_list rename to clang/test/Modules/Inputs/initializer_list/direct.h diff --git a/clang/test/Modules/Inputs/initializer_list/direct.modulemap b/clang/test/Modules/Inputs/initializer_list/direct.modulemap new file mode 100644 index 0000000..56a4100 --- /dev/null +++ b/clang/test/Modules/Inputs/initializer_list/direct.modulemap @@ -0,0 +1 @@ +module initializer_list { header "direct.h" } diff --git a/clang/test/Modules/Inputs/initializer_list/indirect.h b/clang/test/Modules/Inputs/initializer_list/indirect.h new file mode 100644 index 0000000..75e9817 --- /dev/null +++ b/clang/test/Modules/Inputs/initializer_list/indirect.h @@ -0,0 +1 @@ +#include "direct.h" diff --git a/clang/test/Modules/Inputs/initializer_list/indirect.modulemap b/clang/test/Modules/Inputs/initializer_list/indirect.modulemap new file mode 100644 index 0000000..14deacf --- /dev/null +++ b/clang/test/Modules/Inputs/initializer_list/indirect.modulemap @@ -0,0 +1 @@ +module initializer_list { header "indirect.h" } diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index 7040ee7e..8ec3e21 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -296,10 +296,6 @@ module warn_unused_local_typedef { header "warn-unused-local-typedef.h" } -module initializer_list { - header "initializer_list" -} - module using_decl { module a { header "using-decl-a.h" export * } module b { header "using-decl-b.h" export * } diff --git a/clang/test/Modules/initializer_list.cpp b/clang/test/Modules/initializer_list.cpp index 0cbcbbb..ea6e282 100644 --- a/clang/test/Modules/initializer_list.cpp +++ b/clang/test/Modules/initializer_list.cpp @@ -1,7 +1,23 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 +// +// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -I %S/Inputs/initializer_list \ +// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \ +// RUN: %s -verify -std=c++11 +// +// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -I %S/Inputs/initializer_list \ +// RUN: -fmodule-map-file=%S/Inputs/initializer_list/indirect.modulemap \ +// RUN: %s -verify -std=c++11 -DINCLUDE_DIRECT // expected-no-diagnostics + +#ifdef INCLUDE_DIRECT +#include "direct.h" +auto k = {1, 2, 3}; +#endif + @import initializer_list; +auto v = {1, 2, 3}; int n = std::min({1, 2, 3}); -- 2.7.4