reject 'typedef int y; int test(x, y)'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49270 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 243d561..1de1b6b 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -631,6 +631,8 @@
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,
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 9445a48..cae0cbb 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -1415,8 +1415,12 @@
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)) {
diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c
index 15ae7c6..410ac36 100644
--- a/test/Parser/declarators.c
+++ b/test/Parser/declarators.c
@@ -25,4 +25,8 @@
int Array[*(int*)P+A];
}
+typedef int atype;
+int test3(x,
+ atype /* expected-error {{unexpected type name 'atype': expected identifier}} */
+ ) int x, atype; {}
diff --git a/test/Sema/arg-duplicate.c b/test/Sema/arg-duplicate.c
index b57fd95..81cb8fd 100644
--- a/test/Sema/arg-duplicate.c
+++ b/test/Sema/arg-duplicate.c
@@ -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,