aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-10 02:22:51 +0000
committerChris Lattner <sabre@nondot.org>2008-04-10 02:22:51 +0000
commit8123a95c33b792d35c2e4992ba6e27882748fb0d (patch)
tree33cd02a28ced427832214e01d1cfdca997f262b3 /lib/Sema/SemaDecl.cpp
parent05cbe1a44e6143d44aac0e769ba120e8c45f34ce (diff)
Several improvements from Doug Gregor related to default
argument handling. I'll fix up the c89 (void) thing next. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5451ec27c0..803f527e50 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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);