]> granicus.if.org Git - clang/commitdiff
typedef void T;
authorChris Lattner <sabre@nondot.org>
Thu, 10 Apr 2008 02:26:16 +0000 (02:26 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 10 Apr 2008 02:26:16 +0000 (02:26 +0000)
 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

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDecl.cpp
test/Sema/c89.c

index e69891ab1ede86a7edae1a5d330dfe31ec8d3182..5afbfffeee160d4803c818ec7b7b35112c2b6dcc 100644 (file)
@@ -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,
index 803f527e5040ae2769d9ba6ebc0eabdcfbdcd168..27825dbef651ab048b3f7dd7a7d183990b197cd0 100644 (file)
@@ -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);
         }
index 920251535d42c60bb28cc5888d43400b0ae7f46c..70949f0c82dc9d2a4ae73e94042438bbdf26e36c 100644 (file)
@@ -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) {}