summaryrefslogtreecommitdiff
path: root/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default
diff options
context:
space:
mode:
authorSerge Pavlov <sepavloff@gmail.com>2017-06-08 06:31:19 +0000
committerSerge Pavlov <sepavloff@gmail.com>2017-06-08 06:31:19 +0000
commitff4214ddcfab9fd92c15cc01c9c2e17a8f6217ad (patch)
treeb0321360528a81c7305019fb8d1f1d145c6dd4a5 /test/CXX/dcl.decl/dcl.meaning/dcl.fct.default
parent14318c6aa40d7c68c4341f43fbc3d0980f6d21a8 (diff)
downloadclang-ff4214ddcfab9fd92c15cc01c9c2e17a8f6217ad.tar.gz
Do not inherit default arguments for friend function in class template.
A function declared in a friend declaration may have declarations prior to the containing class definition. If such declaration defines default argument, the friend function declaration inherits them. This behavior causes problems if the class where the friend is declared is a template: during the class instantiation the friend function looks like if it had default arguments, so error is triggered. With this change friend functions declared in class templates do not inherit default arguments. Actual set of them will be defined at the point where the containing class is instantiated. This change fixes PR12724. Differential Revision: https://reviews.llvm.org/D30393 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304965 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/dcl.decl/dcl.meaning/dcl.fct.default')
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
index a5ac85cb6f..6014268a18 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
@@ -73,3 +73,36 @@ void Test ()
}
} // namespace
+
+namespace pr12724 {
+
+void func_01(bool param = true);
+class C01 {
+public:
+ friend void func_01(bool param);
+};
+
+void func_02(bool param = true);
+template<typename T>
+class C02 {
+public:
+ friend void func_02(bool param);
+};
+C02<int> c02;
+
+void func_03(bool param);
+template<typename T>
+class C03 {
+public:
+ friend void func_03(bool param);
+};
+void func_03(bool param = true);
+C03<int> c03;
+
+void main() {
+ func_01();
+ func_02();
+ func_03();
+}
+
+} // namespace pr12724