Diagnose attempts to use C++ default arguments outside of a function declaration
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50799 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/default2.cpp b/test/Sema/default2.cpp
index 59489da..d3e999c 100644
--- a/test/Sema/default2.cpp
+++ b/test/Sema/default2.cpp
@@ -1,7 +1,10 @@
// RUN: clang -fsyntax-only -verify %s
void f(int i, int j, int k = 3);
+void f(int i, int j, int k);
void f(int i, int j = 2, int k);
+void f(int i, int j, int k);
void f(int i = 1, int j, int k);
+void f(int i, int j, int k);
void i()
{
@@ -27,3 +30,9 @@
}
void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
+
+void nondecl(int (*f)(int x = 5)) // {expected-error {{default arguments can only be specified}}}
+{
+ void (*f2)(int = 17) // {expected-error {{default arguments can only be specified}}}
+ = (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
+}