]> granicus.if.org Git - clang/commitdiff
reject 'typedef int y; int test(x, y)'.
authorChris Lattner <sabre@nondot.org>
Sun, 6 Apr 2008 06:47:48 +0000 (06:47 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 6 Apr 2008 06:47:48 +0000 (06:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49270 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Parse/ParseDecl.cpp
test/Parser/declarators.c
test/Sema/arg-duplicate.c

index 243d56108be19f5d607efd5cbe9915a0a1eb30d3..1de1b6b80f5206de3465a294bef3385c5e8f5086 100644 (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,
index 9445a4862c68ab31e86b9071dd7816db8e297f84..cae0cbb8ecdf67ebd1b701340989a7669ed938a8 100644 (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)) {
index 15ae7c6b577c01c202a2683b1ec5767a9147f516..410ac3686f12617ec9b8275f6e2041134990be68 100644 (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; {}
 
index b57fd950bf104fa8f3f8d673391f4daec5258486..81cb8fd9c29f1ae640af5946e1b29ab2b92c319f 100644 (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,