]> granicus.if.org Git - clang/commitdiff
in:
authorChris Lattner <sabre@nondot.org>
Sat, 25 Apr 2009 05:51:56 +0000 (05:51 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 25 Apr 2009 05:51:56 +0000 (05:51 +0000)
typedef void foo(void);

We get a typedef for a functiontypeproto with no arguments, not
one with one argument and type void.  This means the code being
removed in SemaDecl is dead.

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

lib/Sema/SemaDecl.cpp
test/Sema/function.c

index c929acf795a71ce29dd186b9856c0885e83eaab1..d34b20780e83df04bb6d1e333b700a2c5f2d2395 100644 (file)
@@ -2153,7 +2153,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
     }
   
     NewFD->setParams(Context, &Params[0], Params.size());
-  } else if (R->getAsTypedefType()) {
+  } else if (isa<TypedefType>(R)) {
     // When we're declaring a function with a typedef, as in the
     // following example, we'll need to synthesize (unnamed)
     // parameters for use in the declaration.
@@ -2162,15 +2162,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
     // typedef void fn(int);
     // fn f;
     // @endcode
-    const FunctionProtoType *FT = R->getAsFunctionProtoType();
-    if (!FT) {
-      // This is a typedef of a function with no prototype, so we
-      // don't need to do anything.
-    } else if ((FT->getNumArgs() == 0) ||
-               (FT->getNumArgs() == 1 && !FT->isVariadic() &&
-                FT->getArgType(0)->isVoidType())) {
-      // This is a zero-argument function. We don't need to do anything.
-    } else {
+    if (const FunctionProtoType *FT = R->getAsFunctionProtoType()) {
       // Synthesize a parameter for each argument type.
       llvm::SmallVector<ParmVarDecl*, 16> Params;
       for (FunctionProtoType::arg_type_iterator ArgType = FT->arg_type_begin();
index 77557c940859230afb331bbd36328fe0b138b20b..a1dd8b69e0300d860cb8605bfe8dba7d40eada13 100644 (file)
@@ -76,4 +76,7 @@ gnu_inline2() {}
 inline foo_t invalid_type() {  // expected-error {{unknown type name 'foo_t'}}
 }
 
+typedef void fn_t(void);
+fn_t t17;
+