Diagnose attempts to use C++ default arguments outside of a function declaration

llvm-svn: 50799
diff --git a/clang/test/Sema/default2.cpp b/clang/test/Sema/default2.cpp
index 59489da..d3e999c 100644
--- a/clang/test/Sema/default2.cpp
+++ b/clang/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}}}
+}