summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--clang/lib/Sema/SemaDecl.cpp6
-rw-r--r--clang/test/Sema/c89.c4
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) {}
OpenPOWER on IntegriCloud