From 69497c315fd2bfebc7b7a8180d9125fa8b17b292 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 16 Dec 2008 00:08:34 +0000 Subject: [PATCH] Added a test for default arguments added to out-of-line member functions. They work except that name lookup within the default arguments needs to be deferred until the class definition is complete (see FIXME in the test). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61059 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/SemaCXX/default2.cpp | 26 ++++++++++++++++++++++++++ www/cxx_status.html | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp index d55045df78..6a8bcb121c 100644 --- a/test/SemaCXX/default2.cpp +++ b/test/SemaCXX/default2.cpp @@ -44,3 +44,29 @@ class X { int f(X* x = this); // expected-error{{default argument references 'this'}} } }; + +// C++ [dcl.fct.default]p6 +class C { + static int x; + void f(int i = 3); // expected-note{{previous definition is here}} + void g(int i, int j = x); + + void h(); +}; +void C::f(int i = 3) // expected-error{{redefinition of default argument}} +{ } + +void C::g(int i = 88, int j) {} + +void C::h() { + g(); // okay +} + +// C++ [dcl.fct.default]p9 +class Y { + int a; + int mem1(int i = a); // expected-error{{invalid use of nonstatic data member 'a'}} + // FIXME: The code below is well-formed. + // int mem2(int i = b); // OK; use X::b + static int b; +}; diff --git a/www/cxx_status.html b/www/cxx_status.html index 4b73b67f60..2bb64e9a71 100644 --- a/www/cxx_status.html +++ b/www/cxx_status.html @@ -853,9 +853,9 @@ welcome!

    8.3.6 [dcl.fct.default] - + - Missing default arguments for out-of-line member functions, templates. + Missing default arguments for templates.   8.4 [dcl.fct.def]   8.5 [dcl.init] -- 2.40.0