aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-10 02:26:16 +0000
committerChris Lattner <sabre@nondot.org>2008-04-10 02:26:16 +0000
commitdef026a193b8218a58d112414515cb87fdf89c15 (patch)
tree520c20a306d18b30c2c55cd8975a63f3e83b9cc0
parent8123a95c33b792d35c2e4992ba6e27882748fb0d (diff)
typedef void T;
void f(T); is only invalid in C++ mode, not C89 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49460 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--test/Sema/c89.c4
3 files changed, 7 insertions, 5 deletions
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index e69891ab1e..5afbfffeee 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/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/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 803f527e50..27825dbef6 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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/test/Sema/c89.c b/test/Sema/c89.c
index 920251535d..70949f0c82 100644
--- a/test/Sema/c89.c
+++ b/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) {}