diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-04-10 02:26:16 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-04-10 02:26:16 +0000 |
| commit | 0e91b419023b9270ee6cc36982bebb4e68f4a837 (patch) | |
| tree | 4173f19944d5ad94d8031faf5fdd8142550aa8ce | |
| parent | 58258246ec920a7c83f8c2fd8b46646f8336f68b (diff) | |
| download | bcm5719-llvm-0e91b419023b9270ee6cc36982bebb4e68f4a837.tar.gz bcm5719-llvm-0e91b419023b9270ee6cc36982bebb4e68f4a837.zip | |
typedef void T;
void f(T);
is only invalid in C++ mode, not C89 mode.
llvm-svn: 49460
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Sema/c89.c | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index e69891ab1ed..5afbfffeee1 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -621,7 +621,7 @@ DIAG(err_no_matching_param, ERROR, DIAG(ext_param_not_declared, EXTENSION, "parameter '%0' was not declared, defaulting to type 'int'") DIAG(ext_param_typedef_of_void, EXTENSION, - "empty parameter list defined with a typedef of 'void' is a C99 feature") + "empty parameter list defined with a typedef of 'void' not allowed in C++") DIAG(err_param_default_argument, ERROR, "C does not support default arguments") DIAG(err_param_default_argument_redefinition, ERROR, diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 803f527e504..27825dbef65 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -841,9 +841,9 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { // 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 && + // In C++, the empty parameter-type-list must be spelled "void"; a + // typedef of void is not permitted. + if (getLangOptions().CPlusPlus && Param->getType() != Context.VoidTy) { Diag(Param->getLocation(), diag::ext_param_typedef_of_void); } diff --git a/clang/test/Sema/c89.c b/clang/test/Sema/c89.c index 920251535d4..70949f0c82d 100644 --- a/clang/test/Sema/c89.c +++ b/clang/test/Sema/c89.c @@ -55,5 +55,7 @@ void z; { bar (&z); } typedef void T; -void foo(T); /* expected-warning {{empty parameter list defined with a typedef of 'void' is a C99 feature}} */ +void foo(T); /* typedef for void is allowed */ + +void foo(void) {} |

