diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-13 05:56:40 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-13 05:56:40 +0000 |
commit | b03a9df68140a393cbef73a23115a0818aff6010 (patch) | |
tree | 75b89db476c06c265a3a4aab3f259a35acd69960 /lib/Sema/SemaDecl.cpp | |
parent | 65daef179790a02eab1b5a989f53984375a06483 (diff) |
PR11925: A function can't have a variably-modified return type. Not even in C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index bee542234b..57b0e9d9c5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5266,21 +5266,22 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, ProcessDeclAttributes(S, NewFD, D, /*NonInheritable=*/true, /*Inheritable=*/false); + // Functions returning a variably modified type violate C99 6.7.5.2p2 + // because all functions have linkage. + if (!NewFD->isInvalidDecl() && + NewFD->getResultType()->isVariablyModifiedType()) { + Diag(NewFD->getLocation(), diag::err_vm_func_decl); + NewFD->setInvalidDecl(); + } + if (!getLangOpts().CPlusPlus) { // Perform semantic checking on the function declaration. bool isExplicitSpecialization=false; if (!NewFD->isInvalidDecl()) { - 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); - NewFD->setInvalidDecl(); - } else { - if (NewFD->isMain()) - CheckMain(NewFD, D.getDeclSpec()); - D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous, - isExplicitSpecialization)); - } + if (NewFD->isMain()) + CheckMain(NewFD, D.getDeclSpec()); + D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous, + isExplicitSpecialization)); } assert((NewFD->isInvalidDecl() || !D.isRedeclaration() || Previous.getResultKind() != LookupResult::FoundOverloaded) && |