types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71941
91177308-0d34-0410-b5e6-
96231b3b80d8
if (NewFD->isInvalidDecl())
return;
+ if (NewFD->getResultType()->isVariablyModifiedType()) {
+ // Functions returning a variably modified type violate C99 6.7.5.2p2
+ // because all functions have linkage.
+ Diag(NewFD->getLocation(), diag::err_vm_func_decl);
+ return NewFD->setInvalidDecl();
+ }
+
// Semantic checking for this function declaration (in isolation).
if (getLangOptions().CPlusPlus) {
// C++-specific checks.
int a[*]; // expected-error {{star modifier used outside of function prototype}}
int f4(int a[*][*]);
+
+// PR2044
+int pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}}
+int pr2044b;
+int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}}