From: Argyrios Kyrtzidis Date: Tue, 7 May 2013 19:54:28 +0000 (+0000) Subject: Try to recognise hidden tag type names in potential declarations, in ObjC code as... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=99e9fe08bbba3d71db41cfd7585b9658ee85ef55;p=clang Try to recognise hidden tag type names in potential declarations, in ObjC code as well. rdar://13829073 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181345 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index e0e8bd646b..a50b5e7c7f 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -858,18 +858,16 @@ Corrected: // Check for a tag type hidden by a non-type decl in a few cases where it // seems likely a type is wanted instead of the non-type that was found. - if (!getLangOpts().ObjC1) { - bool NextIsOp = NextToken.is(tok::amp) || NextToken.is(tok::star); - if ((NextToken.is(tok::identifier) || - (NextIsOp && FirstDecl->isFunctionOrFunctionTemplate())) && - isTagTypeWithMissingTag(*this, Result, S, SS, Name, NameLoc)) { - TypeDecl *Type = Result.getAsSingle(); - DiagnoseUseOfDecl(Type, NameLoc); - QualType T = Context.getTypeDeclType(Type); - if (SS.isNotEmpty()) - return buildNestedType(*this, SS, T, NameLoc); - return ParsedType::make(T); - } + bool NextIsOp = NextToken.is(tok::amp) || NextToken.is(tok::star); + if ((NextToken.is(tok::identifier) || + (NextIsOp && FirstDecl->isFunctionOrFunctionTemplate())) && + isTagTypeWithMissingTag(*this, Result, S, SS, Name, NameLoc)) { + TypeDecl *Type = Result.getAsSingle(); + DiagnoseUseOfDecl(Type, NameLoc); + QualType T = Context.getTypeDeclType(Type); + if (SS.isNotEmpty()) + return buildNestedType(*this, SS, T, NameLoc); + return ParsedType::make(T); } if (FirstDecl->isCXXClassMember()) diff --git a/test/SemaCXX/decl-expr-ambiguity.cpp b/test/SemaCXX/decl-expr-ambiguity.cpp index 87fd2dad31..8164b2bc91 100644 --- a/test/SemaCXX/decl-expr-ambiguity.cpp +++ b/test/SemaCXX/decl-expr-ambiguity.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s +// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s void f() { int a;