diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-03-04 07:30:59 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-03-04 07:30:59 +0000 |
| commit | 9ad7244f5b44ffeb3f753d2c44c5e87397d5e4e7 (patch) | |
| tree | e7745bcc125e4f7e6d0d0660f66191e9470a4ebd /clang/lib/Sema/SemaDecl.cpp | |
| parent | a954a99c403432338406da3752a2ab5da598f2b0 (diff) | |
| download | bcm5719-llvm-9ad7244f5b44ffeb3f753d2c44c5e87397d5e4e7.tar.gz bcm5719-llvm-9ad7244f5b44ffeb3f753d2c44c5e87397d5e4e7.zip | |
Check that the return type for function definitions is complete.
llvm-svn: 66027
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 38807925169..e1b27c64a4d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2453,6 +2453,14 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) { } } + // The return type of a function definition must be complete + // (C99 6.9.1p3) + if (FD->getResultType()->isIncompleteType() && + !FD->getResultType()->isVoidType()) { + Diag(FD->getLocation(), diag::err_func_def_incomplete_result) << FD; + FD->setInvalidDecl(); + } + PushDeclContext(FnBodyScope, FD); // Check the validity of our function parameters |

