[cfe-commits] r163224 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/invalid-decl.c

Fariborz Jahanian fjahanian at apple.com
Wed Sep 5 10:52:13 PDT 2012


Author: fjahanian
Date: Wed Sep  5 12:52:12 2012
New Revision: 163224

URL: http://llvm.org/viewvc/llvm-project?rev=163224&view=rev
Log:
c error recovery. treat an invalid redeclaration
of a c-function for what it is. Otherwise, this func
is treated as an overloadable c-function resulting in
a crash much later. // rdar://11743706

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/invalid-decl.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=163224&r1=163223&r2=163224&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep  5 12:52:12 2012
@@ -5565,6 +5565,9 @@
       D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous,
                                                   isExplicitSpecialization));
     }
+    // Make graceful recovery from an invalid redeclaration.
+    else if (!Previous.empty())
+           D.setRedeclaration(true);
     assert((NewFD->isInvalidDecl() || !D.isRedeclaration() ||
             Previous.getResultKind() != LookupResult::FoundOverloaded) &&
            "previous declaration set still overloaded");

Modified: cfe/trunk/test/Sema/invalid-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-decl.c?rev=163224&r1=163223&r2=163224&view=diff
==============================================================================
--- cfe/trunk/test/Sema/invalid-decl.c (original)
+++ cfe/trunk/test/Sema/invalid-decl.c Wed Sep  5 12:52:12 2012
@@ -29,3 +29,12 @@
 void f(StructType *buf) {
   buf->fun = 0;
 }
+
+// rdar://11743706
+static void bar(hid_t, char); // expected-error {{expected identifier}}
+
+static void bar(hid_t p, char); // expected-error {{unknown type name 'hid_t'}}
+
+void foo() {
+  (void)bar;
+}





More information about the cfe-commits mailing list