diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 6 | ||||
-rw-r--r-- | clang/test/Parser/declarators.c | 4 | ||||
-rw-r--r-- | clang/test/Sema/arg-duplicate.c | 1 |
4 files changed, 11 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index 243d56108be..1de1b6b80f5 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -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, diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 9445a4862c6..cae0cbb8ecd 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -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)) { diff --git a/clang/test/Parser/declarators.c b/clang/test/Parser/declarators.c index 15ae7c6b577..410ac3686f1 100644 --- a/clang/test/Parser/declarators.c +++ b/clang/test/Parser/declarators.c @@ -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; {} diff --git a/clang/test/Sema/arg-duplicate.c b/clang/test/Sema/arg-duplicate.c index b57fd950bf1..81cb8fd9c29 100644 --- a/clang/test/Sema/arg-duplicate.c +++ b/clang/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, |