diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-04-25 05:51:56 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-04-25 05:51:56 +0000 |
| commit | ae4ee5be22642b227d623b0a1b10e7c48d24afa2 (patch) | |
| tree | 4d97628cf5c85e9c593c8c332e9b6d477c180671 | |
| parent | 68f1d8ed0c83a76630324b31479b3698b3f13521 (diff) | |
| download | bcm5719-llvm-ae4ee5be22642b227d623b0a1b10e7c48d24afa2.tar.gz bcm5719-llvm-ae4ee5be22642b227d623b0a1b10e7c48d24afa2.zip | |
in:
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.
llvm-svn: 70013
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Sema/function.c | 3 |
2 files changed, 5 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c929acf795a..d34b20780e8 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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(); diff --git a/clang/test/Sema/function.c b/clang/test/Sema/function.c index 77557c94085..a1dd8b69e03 100644 --- a/clang/test/Sema/function.c +++ b/clang/test/Sema/function.c @@ -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; + |

