reject 'typedef int y; int test(x, y)'.

llvm-svn: 49270
This commit is contained in:
Chris Lattner 2008-04-06 06:47:48 +00:00
parent 9186f556cc
commit 67b450cb48
4 changed files with 11 additions and 2 deletions

View File

@ -631,6 +631,8 @@ DIAG(err_first_label, ERROR,
DIAG(err_unexpected_typedef, ERROR,
"unexpected type name '%0': expected expression")
DIAG(err_unexpected_typedef_ident, ERROR,
"unexpected type name '%0': expected identifier")
DIAG(err_undeclared_var_use, ERROR,
"use of undeclared identifier '%0'")
DIAG(warn_deprecated, WARNING,

View File

@ -1415,8 +1415,12 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
SkipUntil(tok::r_paren);
return;
}
IdentifierInfo *ParmII = Tok.getIdentifierInfo();
// Reject 'typedef int y; int test(x, y)', but continue parsing.
if (Actions.isTypeName(*ParmII, CurScope))
Diag(Tok, diag::err_unexpected_typedef_ident, ParmII->getName());
// Verify that the argument identifier has not already been mentioned.
if (!ParamsSoFar.insert(ParmII)) {

View File

@ -25,4 +25,8 @@ int test2(int *P, int A) {
int Array[*(int*)P+A];
}
typedef int atype;
int test3(x,
atype /* expected-error {{unexpected type name 'atype': expected identifier}} */
) int x, atype; {}

View File

@ -1,6 +1,5 @@
// RUN: clang -fsyntax-only -verify %s
typedef int x;
int f3(y, x,
x) // expected-error {{redefinition of parameter}}
int y, x,