diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-25 06:12:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-25 06:12:16 +0000 |
commit | 2dbd285f5033ca6dea25babfd1c43d9fec35e7e5 (patch) | |
tree | e3a1f6f14316cf44f45dcc28f142ca4db08487b3 /lib/AST/Decl.cpp | |
parent | 1ad9b28e3217c2349a04f3d3bf14f9c73a99afa7 (diff) |
fix PR4049, a crash on invalid, by making sema install the right number of
parameters in a functiondecl, even if the decl is invalid and has a confusing
Declarator. On the testcase, we now emit one beautiful diagnostic:
t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*)
^
GCC 4.0 produces:
t.c:2: error: syntax error before ‘f’
t.c: In function ‘f’:
t.c:2: error: parameter name omitted
and GCC 4.2:
t.c:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘f’
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70016 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 57a44e54d8..1dd782936f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -432,7 +432,7 @@ unsigned FunctionDecl::getBuiltinID(ASTContext &Context) const { /// getNumParams - Return the number of parameters this function must have -/// based on its functiontype. This is the length of the PararmInfo array +/// based on its FunctionType. This is the length of the PararmInfo array /// after it has been created. unsigned FunctionDecl::getNumParams() const { const FunctionType *FT = getType()->getAsFunctionType(); @@ -445,8 +445,7 @@ unsigned FunctionDecl::getNumParams() const { void FunctionDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo, unsigned NumParams) { assert(ParamInfo == 0 && "Already has param info!"); - assert(NumParams == getNumParams() && - "Parameter count mismatch!"); + assert(NumParams == getNumParams() && "Parameter count mismatch!"); // Zero params -> null pointer. if (NumParams) { |