[cfe-commits] r49270 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Parse/ParseDecl.cpp test/Parser/declarators.c test/Sema/arg-duplicate.c

Chris Lattner sabre at nondot.org
Sat Apr 5 23:47:49 PDT 2008


Author: lattner
Date: Sun Apr  6 01:47:48 2008
New Revision: 49270

URL: http://llvm.org/viewvc/llvm-project?rev=49270&view=rev
Log:
reject 'typedef int y; int test(x, y)'.


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

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=49270&r1=49269&r2=49270&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Sun Apr  6 01:47:48 2008
@@ -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,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=49270&r1=49269&r2=49270&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Apr  6 01:47:48 2008
@@ -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)) {

Modified: cfe/trunk/test/Parser/declarators.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/declarators.c?rev=49270&r1=49269&r2=49270&view=diff

==============================================================================
--- cfe/trunk/test/Parser/declarators.c (original)
+++ cfe/trunk/test/Parser/declarators.c Sun Apr  6 01:47:48 2008
@@ -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; {}
 

Modified: cfe/trunk/test/Sema/arg-duplicate.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arg-duplicate.c?rev=49270&r1=49269&r2=49270&view=diff

==============================================================================
--- cfe/trunk/test/Sema/arg-duplicate.c (original)
+++ cfe/trunk/test/Sema/arg-duplicate.c Sun Apr  6 01:47:48 2008
@@ -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, 





More information about the cfe-commits mailing list