Clang Project

clang_source_code/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2
3void nondecl(int (*f)(int x = 5)) // expected-error {{default arguments can only be specified}}
4{
5  void (*f2)(int = 17)  // expected-error {{default arguments can only be specified}}
6  = (void (*)(int = 42))f; // expected-error {{default arguments can only be specified}}
7}
8
9struct X0 {
10  int (*f)(int = 17); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
11  void (*g())(int = 22); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
12  void (*h(int = 49))(int);
13  auto i(int) -> void (*)(int = 9); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
14  
15  void mem8(int (*fp)(int) = (int (*)(int = 17))0); // expected-error{{default arguments can only be specified for parameters in a function declaration}}  
16};
17
18template <typename... Ts>
19void defaultpack(Ts... = 0) {} // expected-error{{parameter pack cannot have a default argument}}
20