PR2044: reject declarations of functions returning variably modified

types.

llvm-svn: 71941
This commit is contained in:
Eli Friedman 2009-05-16 12:15:55 +00:00
parent 0b4af8f755
commit 54135838e2
2 changed files with 12 additions and 0 deletions

View File

@ -2344,6 +2344,13 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
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.

View File

@ -46,3 +46,8 @@ static const unsigned array[((2 * (int)((((4) / 2) + 1.0/3.0) * (4) - 1e-8)) + 1
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}}