llvm-project/clang/test
Serge Pavlov 06b7a87298 Do not find friend function definitions inside non-instantiated class.
Previously if a file-level function was defined inside befriending
template class, it always was treated as defined. For instance, the code like:
```
  int func(int x);
  template<typename T> class C1 {
    friend int func(int x) { return x; }
  };
  template<typename T> class C2 {
    friend int func(int x) { return x; }
  };
```
could not be compiled due to function redefinition, although not of the templates
is instantiated. Moreover, the body of friend function can contain use of template
parameters, attempt to get definition of such function outside any instantiation
causes compiler abnormal termination.

Other compilers (gcc, icc) follow viewpoint that the body of the function defined
in friend declaration becomes available when corresponding class is instantiated.
This patch implements this viewpoint in clang.

Definitions introduced by friend declarations in template classes are not added
to the redeclaration chain of corresponding function. Only when the template is
instantiated, instantiation of the function definition is placed to the chain.

The fix was made in collaboration with Richard Smith.

This change fixes PR8035, PR17923, PR22307 and PR25848.

Differential Revision: http://reviews.llvm.org/D16989

llvm-svn: 283207
2016-10-04 10:11:43 +00:00
..
ARCMT [test/objcmt] Add a follow-up test case for r275600. 2016-07-15 20:40:24 +00:00
ASTMerge ASTMerge: explicitly specify arch for GCCAsmStmt test to calm non-x86 buildbots 2016-09-28 11:04:42 +00:00
Analysis Revert "[analyzer] Improve CloneChecker diagnostics" as its depends on reverted r283092 2016-10-04 02:40:35 +00:00
CXX Fix bogus "inline namespace cannot be reopened as non-inline" diagnostic to 2016-09-30 23:16:08 +00:00
CodeCompletion Implement filtering for code completion of identifiers. 2016-07-27 14:56:59 +00:00
CodeGen [AVX-512] Use native IR for masked 512-bit add/sub/mul/div ps/pd intrinsics when rounding mode isn't used. 2016-10-02 17:43:00 +00:00
CodeGenCUDA [CUDA] Disallow overloading destructors. 2016-10-03 16:48:23 +00:00
CodeGenCXX Keep the test only for Itanium abi 2016-10-03 02:36:33 +00:00
CodeGenCoroutines [coroutines] Adding builtins for coroutine intrinsics and backendutil support. 2016-10-03 22:44:48 +00:00
CodeGenObjC [ARC] Ignore qualifiers in copy-restore expressions 2016-10-03 15:29:22 +00:00
CodeGenObjCXX Re-commit r282556, reverted in r282564, with a fix to CallArgList::addFrom to 2016-09-28 19:09:10 +00:00
CodeGenOpenCL [OpenCL] Fix bug in __builtin_astype causing invalid LLVM cast instructions 2016-10-03 14:41:50 +00:00
Coverage
CoverageMapping [Coverage] The coverage region for switch covers the code after the switch. 2016-09-27 23:30:36 +00:00
Driver Revert "[XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed" 2016-10-04 08:54:51 +00:00
FixIt ObjC Class Property: diagnostics when accessing a class property using instance. 2016-06-28 23:01:49 +00:00
Format Make clang-format remove duplicate headers when sorting #includes. 2016-08-10 09:32:23 +00:00
Frontend CC1: Add -save-stats option 2016-09-26 18:53:34 +00:00
Headers Add some MS aliases for existing intrinsics 2016-09-14 21:19:43 +00:00
Index [index] Fix crash with indexing designated init expressions inside templates. 2016-08-03 05:38:53 +00:00
Integration
Layout [MS ABI] Implement __declspec(empty_bases) and __declspec(layout_version) 2016-05-23 17:16:12 +00:00
Lexer [coroutines] Rename driver flag -fcoroutines to -fcoroutines-ts 2016-10-02 03:31:58 +00:00
Misc Put new warning in a diagnostic group. 2016-09-27 23:44:38 +00:00
Modules ObjectiveC: fix a seg fault when deserialing redeclaration of ObjCMethodDecl. 2016-10-03 21:26:46 +00:00
OpenMP Revert "[OpenMP] Sema and parsing for 'teams distribute simd’ pragma" 2016-08-18 09:25:07 +00:00
PCH P0035R4: add std::align_val_t overloads of operator new/delete in C++17 mode. 2016-09-29 22:49:46 +00:00
Parser [coroutines] Rename driver flag -fcoroutines to -fcoroutines-ts 2016-10-02 03:31:58 +00:00
Preprocessor P0035R4: add predefined __STDCPP_DEFAULT_NEW_ALIGNMENT__ macro. By default, we 2016-09-30 22:41:36 +00:00
Profile [Profile] Enable profile merging with -fprofile-generat[=<dir>] 2016-07-22 22:25:01 +00:00
Rewriter
Sema [Sema] Support lax conversions for compound assignments 2016-09-30 22:19:38 +00:00
SemaCUDA [CUDA] Disallow overloading destructors. 2016-10-03 16:48:23 +00:00
SemaCXX Do not find friend function definitions inside non-instantiated class. 2016-10-04 10:11:43 +00:00
SemaObjC [SemaObjC] Be more strict while parsing type arguments and protocols 2016-09-13 20:04:35 +00:00
SemaObjCXX Sema: support __declspec(dll*) on ObjC interfaces 2016-07-15 20:41:10 +00:00
SemaOpenCL [AMDGPU] Expose flat work group size, register and wave control attributes 2016-09-26 01:02:57 +00:00
SemaTemplate P0127R2: Support type deduction for types of non-type template parameters in 2016-09-28 23:55:27 +00:00
TableGen
Tooling Back out the test case for r266973 for now. 2016-04-21 10:46:14 +00:00
Unit Replace hardcoded comment at 'lit.site.cfg.in' 2016-04-16 06:54:46 +00:00
VFS Don't diagnose non-modular includes when we are not compiling a module. 2016-08-26 17:16:46 +00:00
.clang-format
CMakeLists.txt Revert "[test] Add libLTO as a clang test dependency on Darwin" 2016-08-30 20:36:48 +00:00
TestRunner.sh
cxx-sections.data
lit.cfg XFAIL Driver/darwin-stdlib.cpp if CLANG_DEFAULT_CXX_STDLIB is set 2016-09-29 07:43:08 +00:00
lit.site.cfg.in XFAIL Driver/darwin-stdlib.cpp if CLANG_DEFAULT_CXX_STDLIB is set 2016-09-29 07:43:08 +00:00
make_test_dirs.pl