]> granicus.if.org Git - clang/commitdiff
Fixed a bug whereby, struct tag name matches a typedef/objc-class name
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 12 Oct 2007 16:34:10 +0000 (16:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 12 Oct 2007 16:34:10 +0000 (16:34 +0000)
and hid them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42915 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp
clang.xcodeproj/project.pbxproj
test/Parser/namelookup-bug-1.c [new file with mode: 0644]
test/Parser/namelookup-bug-2.c [new file with mode: 0644]

index 0a63cb9106d763715bab05967ab509e2e1fab01f..7e0a51f5c5f4c46c05f975a4cda9ece95b5eac45 100644 (file)
 using namespace clang;
 
 Sema::DeclTy *Sema::isTypeName(const IdentifierInfo &II, Scope *S) const {
-  if (Decl *IIDecl = II.getFETokenInfo<Decl>())
-    if (isa<TypedefDecl>(IIDecl) || isa<ObjcInterfaceDecl>(IIDecl))
-      return IIDecl;
-    else if (ObjcCompatibleAliasDecl *ADecl = 
-               dyn_cast<ObjcCompatibleAliasDecl>(IIDecl))
-      return ADecl->getClassInterface();
+  Decl *IIDecl = II.getFETokenInfo<Decl>();
+  // Find first occurance of none-tagged declaration
+  while(IIDecl && IIDecl->getIdentifierNamespace() != Decl::IDNS_Ordinary)
+    IIDecl = cast<ScopedDecl>(IIDecl)->getNext();
+  if (!IIDecl)
+    return 0;
+  if (isa<TypedefDecl>(IIDecl) || isa<ObjcInterfaceDecl>(IIDecl))
+    return IIDecl;
+  if (ObjcCompatibleAliasDecl *ADecl = 
+      dyn_cast<ObjcCompatibleAliasDecl>(IIDecl))
+    return ADecl->getClassInterface(); 
   return 0;
 }
 
index b88c381faa0b21298a15082c3f3667bb0e3dacc7..75d938806b0068e9faf478a9935977559b88f772 100644 (file)
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
                        projectDirPath = "";
diff --git a/test/Parser/namelookup-bug-1.c b/test/Parser/namelookup-bug-1.c
new file mode 100644 (file)
index 0000000..298798c
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: clang -verify %s
+
+typedef int Object;
+
+struct Object *pp;
+
+Object staticObject1;
diff --git a/test/Parser/namelookup-bug-2.c b/test/Parser/namelookup-bug-2.c
new file mode 100644 (file)
index 0000000..443b50a
--- /dev/null
@@ -0,0 +1,14 @@
+// RUN: clang -verify %s
+
+typedef int Object;
+
+struct Object {int i1; } *P;
+
+void foo() {
+ struct Object { int i2; } *X;
+  Object:
+ {
+    Object a;
+ }
+}
+