r175869 - In LookupResult::resolveKind(), when handling multiple found declarations, ignore invalid declarations.

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Feb 21 22:58:37 PST 2013


Author: akirtzidis
Date: Fri Feb 22 00:58:37 2013
New Revision: 175869

URL: http://llvm.org/viewvc/llvm-project?rev=175869&view=rev
Log:
In LookupResult::resolveKind(), when handling multiple found declarations, ignore invalid declarations.

This reduces the "ambiguous reference" errors (which are rather strange in C/ObjC) and fixes an assertion hit
with an invalid code test case.

Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/test/Sema/invalid-decl.c
    cfe/trunk/test/SemaObjC/crash-on-objc-bool-literal.m

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=175869&r1=175868&r2=175869&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Feb 22 00:58:37 2013
@@ -371,6 +371,12 @@ void LookupResult::resolveKind() {
     NamedDecl *D = Decls[I]->getUnderlyingDecl();
     D = cast<NamedDecl>(D->getCanonicalDecl());
 
+    // Ignore an invalid declaration unless it's the only one left.
+    if (D->isInvalidDecl() && I < N-1) {
+      Decls[I] = Decls[--N];
+      continue;
+    }
+
     // Redeclarations of types via typedef can occur both within a scope
     // and, through using declarations and directives, across scopes. There is
     // no ambiguity if they all refer to the same type, so unique based on the

Modified: cfe/trunk/test/Sema/invalid-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-decl.c?rev=175869&r1=175868&r2=175869&view=diff
==============================================================================
--- cfe/trunk/test/Sema/invalid-decl.c (original)
+++ cfe/trunk/test/Sema/invalid-decl.c Fri Feb 22 00:58:37 2013
@@ -42,3 +42,7 @@ void foo() {
 void test2();
 void test2(undef); // expected-error {{a parameter list without types is only allowed in a function definition}}
 void test2() { }
+
+void test3();
+void test3; // expected-error {{incomplete type}}
+void test3() { }

Modified: cfe/trunk/test/SemaObjC/crash-on-objc-bool-literal.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/crash-on-objc-bool-literal.m?rev=175869&r1=175868&r2=175869&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/crash-on-objc-bool-literal.m (original)
+++ cfe/trunk/test/SemaObjC/crash-on-objc-bool-literal.m Fri Feb 22 00:58:37 2013
@@ -2,11 +2,10 @@
 // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
 // rdar://12456743
 
-typedef signed char BOOL; // expected-note 2 {{candidate found by name lookup is 'BOOL'}}
+typedef signed char BOOL;
 
-EXPORT BOOL FUNC(BOOL enabled); // expected-error {{unknown type name 'EXPORT'}} // expected-error {{expected ';' after top level declarator}} \
-                                // expected-note 2 {{candidate found by name lookup is 'BOOL'}}
+EXPORT BOOL FUNC(BOOL enabled); // expected-error {{unknown type name 'EXPORT'}} // expected-error {{expected ';' after top level declarator}}
 
-static inline BOOL MFIsPrivateVersion(void) { // expected-error {{reference to 'BOOL' is ambiguous}}
- return __objc_yes; // expected-error {{reference to 'BOOL' is ambiguous}}
+static inline BOOL MFIsPrivateVersion(void) {
+ return __objc_yes;
 }





More information about the cfe-commits mailing list