]> granicus.if.org Git - clang/commitdiff
Implement DR577
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 19 Feb 2014 03:00:56 +0000 (03:00 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 19 Feb 2014 03:00:56 +0000 (03:00 +0000)
DR18 previously forebode typedefs to be used as parameter types if they
were of type 'void'.  DR577 allows 'void' to be used as a function
parameter type regardless from where it came.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201631 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/SemaDecl.cpp
lib/Sema/SemaLambda.cpp
test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
test/CXX/drs/dr0xx.cpp
test/SemaCXX/alias-template.cpp

index e4d0f941b726ed15106e225c60e3a963e6700310..8984116ad0e91549a1ddecd251cdedffc92c8248 100644 (file)
@@ -2510,8 +2510,6 @@ def err_ident_list_in_fn_declaration : Error<
   "a parameter list without types is only allowed in a function definition">;
 def ext_param_not_declared : Extension<
   "parameter %0 was not declared, defaulting to type 'int'">;
-def err_param_typedef_of_void : Error<
-  "empty parameter list defined with a %select{typedef|type alias}0 of 'void' not allowed%select{ in C++|}0">;
 def err_param_default_argument : Error<
   "C does not support default arguments">;
 def err_param_default_argument_redefinition : Error<
index 894e43493f69185ffbd2c11f1e1ecb9284f7085c..9cb6635c3fd163a362949917903698cbc553b4d9 100644 (file)
@@ -1521,7 +1521,6 @@ public:
                                      MultiTemplateParamsArg TemplateParamLists,
                                      bool &AddToScope);
   bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
-  void checkVoidParamDecl(ParmVarDecl *Param);
 
   bool CheckConstexprFunctionDecl(const FunctionDecl *FD);
   bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body);
index 72210757f34b890df800023648760b1c1593d550..c147681f03fc6e6136a09803db8bf54b3984be14 100644 (file)
@@ -6357,22 +6357,6 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,
   }
 }
 
-void Sema::checkVoidParamDecl(ParmVarDecl *Param) {
-  // In C++, the empty parameter-type-list must be spelled "void"; a
-  // typedef of void is not permitted.
-  if (getLangOpts().CPlusPlus &&
-      Param->getType().getUnqualifiedType() != Context.VoidTy) {
-    bool IsTypeAlias = false;
-    if (const TypedefType *TT = Param->getType()->getAs<TypedefType>())
-      IsTypeAlias = isa<TypeAliasDecl>(TT->getDecl());
-    else if (const TemplateSpecializationType *TST =
-               Param->getType()->getAs<TemplateSpecializationType>())
-      IsTypeAlias = TST->isTypeAlias();
-    Diag(Param->getLocation(), diag::err_param_typedef_of_void)
-      << IsTypeAlias;
-  }
-}
-
 enum OpenCLParamType {
   ValidKernelParam,
   PtrPtrKernelParam,
@@ -6915,7 +6899,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
         FTI.ArgInfo[0].Param &&
         cast<ParmVarDecl>(FTI.ArgInfo[0].Param)->getType()->isVoidType()) {
       // Empty arg list, don't push any params.
-      checkVoidParamDecl(cast<ParmVarDecl>(FTI.ArgInfo[0].Param));
     } else if (FTI.NumArgs > 0 && FTI.ArgInfo[0].Param != 0) {
       for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
         ParmVarDecl *Param = cast<ParmVarDecl>(FTI.ArgInfo[i].Param);
index 8c1b57fd0faf4d3f978cb03a3b56225ca7991277..0e10bfdf6f84c78e5c655b2d275cef96dec6299a 100644 (file)
@@ -901,7 +901,6 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
     if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
         cast<ParmVarDecl>(FTI.ArgInfo[0].Param)->getType()->isVoidType()) {
       // Empty arg list, don't push any params.
-      checkVoidParamDecl(cast<ParmVarDecl>(FTI.ArgInfo[0].Param));
     } else {
       Params.reserve(FTI.NumArgs);
       for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
index 89a28adcc65c1f911cdaa654de639a6fb8484c89..cc44f74a5547eb81a1c794f70ab24cab2e76cb61 100644 (file)
@@ -154,5 +154,5 @@ namespace Access {
 namespace VoidArg {
   using V = void;
   V f(int); // ok
-  V g(V); // expected-error {{empty parameter list defined with a type alias of 'void' not allowed}}
+  V g(V); // ok (DR577)
 }
index 9f6f2eaef11b3084359369c3ab8cb99cab8a5f85..f11bb9d68736e0e56bbfa0f8dadb5949f8b48420 100644 (file)
@@ -194,10 +194,7 @@ namespace dr17 { // dr17: yes
   };
 }
 
-namespace dr18 { // dr18: yes
-  typedef void Void;
-  void f(Void); // expected-error {{empty parameter list defined with a typedef of 'void'}}
-}
+// dr18: sup 577
 
 namespace dr19 { // dr19: yes
   struct A {
index db9c82afd59852f852e945ada5eac34f02e3a7b3..5b3c3146368eb83bba9729e2c4186d3d6c2ec2b6 100644 (file)
@@ -136,7 +136,7 @@ namespace Access {
 namespace VoidArg {
   template<typename Z> using V = void;
   V<int> f(int); // ok
-  V<char> g(V<double>); // expected-error {{empty parameter list defined with a type alias of 'void' not allowed}}
+  V<char> g(V<double>); // ok (DR577)
 }
 
 namespace Curried {