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
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index e69891a..5afbfff 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -621,7 +621,7 @@
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 803f527..27825db 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -841,9 +841,9 @@
// 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 9202515..70949f0 100644
--- a/test/Sema/c89.c
+++ b/test/Sema/c89.c
@@ -55,5 +55,7 @@
{ 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) {}