diff options
author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-03-16 11:17:04 +0000 |
---|---|---|
committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-03-16 11:17:04 +0000 |
commit | 632eac34281c922bb52d30762bdc7115aa925698 (patch) | |
tree | 70fc9e997018b8460a3667ac6b189d95564889d1 /clang/test | |
parent | d3fe3aa57f1f2ddc51462f049c4f42d60823070b (diff) | |
download | bcm5719-llvm-632eac34281c922bb52d30762bdc7115aa925698.tar.gz bcm5719-llvm-632eac34281c922bb52d30762bdc7115aa925698.zip |
[modules] Fix adding a templated friend functions to a namespace from another module.
When clang adds argument dependent lookup candidates, it can perform template
instantiation. For example, it can instantiate a templated friend function and
register it in the enclosing namespace's lookup table.
Fixes https://llvm.org/bugs/show_bug.cgi?id=24954
Reviewed by Richard Smith.
llvm-svn: 263634
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Modules/Inputs/PR24954/A.h | 10 | ||||
-rw-r--r-- | clang/test/Modules/Inputs/PR24954/B.h | 30 | ||||
-rw-r--r-- | clang/test/Modules/Inputs/PR24954/module.modulemap | 9 | ||||
-rw-r--r-- | clang/test/Modules/pr24954.cpp | 7 |
4 files changed, 56 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/PR24954/A.h b/clang/test/Modules/Inputs/PR24954/A.h new file mode 100644 index 00000000000..5e5d5bf92ce --- /dev/null +++ b/clang/test/Modules/Inputs/PR24954/A.h @@ -0,0 +1,10 @@ +#include "B.h" + +template <class T> +class Expr { +public: + void print(B::basic_ostream<char>& os) { + os << B::setw(42); + os << B::endl; + } +}; diff --git a/clang/test/Modules/Inputs/PR24954/B.h b/clang/test/Modules/Inputs/PR24954/B.h new file mode 100644 index 00000000000..a8ddc718927 --- /dev/null +++ b/clang/test/Modules/Inputs/PR24954/B.h @@ -0,0 +1,30 @@ +namespace B { + + template <class _CharT> + struct basic_ostream { + basic_ostream& operator<<(basic_ostream& (*__pf)()); + }; + + + template <class _CharT> basic_ostream<_CharT>& + endl(); + + struct S1 { + template <class _CharT> friend void + operator<<(basic_ostream<_CharT>& __os, const S1& __x); + }; + + S1 setw(int __n); + + template <class _CharT> class S2; + + template <class _CharT> void + operator<<(basic_ostream<_CharT>& __os, const S2<_CharT>& __x); + + template <class _CharT> + struct S2 { + template <class _Cp> friend void + operator<<(basic_ostream<_Cp>& __os, const S2<_Cp>& __x); + }; + +} diff --git a/clang/test/Modules/Inputs/PR24954/module.modulemap b/clang/test/Modules/Inputs/PR24954/module.modulemap new file mode 100644 index 00000000000..49374181d75 --- /dev/null +++ b/clang/test/Modules/Inputs/PR24954/module.modulemap @@ -0,0 +1,9 @@ +module A { + header "A.h" + export * +} + +module B { + header "B.h" + export * +} diff --git a/clang/test/Modules/pr24954.cpp b/clang/test/Modules/pr24954.cpp new file mode 100644 index 00000000000..407ee06e402 --- /dev/null +++ b/clang/test/Modules/pr24954.cpp @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -I%S/Inputs/PR24954 -verify %s +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/PR24954 -verify %s + +#include "A.h" + +// expected-no-diagnostics |