diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-10 02:22:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-10 02:22:51 +0000 |
commit | 58258246ec920a7c83f8c2fd8b46646f8336f68b (patch) | |
tree | 6e95a9d718f3a3c3477da857719d496224eca851 /clang/lib/Sema/SemaDecl.cpp | |
parent | a29d2536aa5c35d8920518fa3c3401aedc310909 (diff) | |
download | bcm5719-llvm-58258246ec920a7c83f8c2fd8b46646f8336f68b.tar.gz bcm5719-llvm-58258246ec920a7c83f8c2fd8b46646f8336f68b.zip |
Several improvements from Doug Gregor related to default
argument handling. I'll fix up the c89 (void) thing next.
llvm-svn: 49459
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5451ec27c05..803f527e504 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -833,17 +833,21 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { // Check for C99 6.7.5.3p10 - foo(void) is a non-varargs // function that takes no arguments, not a function that takes a - // single void argument. FIXME: Is this really the right place - // to check for this? C++ says that the parameter list (void) is - // the same as an empty parameter list, whereas the parameter - // list (T) (with T typedef'd to void) is not. For C++, this - // should be handled in the parser. Check C89 and C99 standards - // to see what the correct behavior is. + // single void argument. if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 && FTI.ArgInfo[0].Param && !((ParmVarDecl*)FTI.ArgInfo[0].Param)->getType().getCVRQualifiers() && ((ParmVarDecl*)FTI.ArgInfo[0].Param)->getType()->isVoidType()) { // empty arg list, don't push any params. + ParmVarDecl *Param = (ParmVarDecl*)FTI.ArgInfo[0].Param; + + // In C++ and C89, the empty parameter-type-list must be + // spelled "void"; a typedef of void is not permitted. + if (!getLangOptions().C99 && + Param->getType() != Context.VoidTy) { + Diag(Param->getLocation(), diag::ext_param_typedef_of_void); + } + } else { for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) Params.push_back((ParmVarDecl *)FTI.ArgInfo[i].Param); |