Skip to content

Commit

Permalink
[modules] Properly check whether a declaration is std::initializer_li…
Browse files Browse the repository at this point in the history
…st. 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230303 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
zygoloid committed Feb 24, 2015
1 parent 4b16d54 commit 09f959d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions test/Modules/Inputs/initializer_list/direct.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module initializer_list { header "direct.h" }
1 change: 1 addition & 0 deletions test/Modules/Inputs/initializer_list/indirect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "direct.h"
1 change: 1 addition & 0 deletions test/Modules/Inputs/initializer_list/indirect.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module initializer_list { header "indirect.h" }
4 changes: 0 additions & 4 deletions test/Modules/Inputs/module.map
Original file line number Diff line number Diff line change
Expand Up @@ -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 * }
Expand Down
18 changes: 17 additions & 1 deletion test/Modules/initializer_list.cpp
Original file line number Diff line number Diff line change
@@ -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});

0 comments on commit 09f959d

Please sign in to comment.