diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-08-11 05:20:41 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-08-11 05:20:41 +0000 |
| commit | ae438f8c03a6f7c30f31bc082c3083ee0d0bf1f4 (patch) | |
| tree | 0315f03a1379eae1cfbd1171a4c01fcb27ca95ef /clang/lib/Sema/SemaExprCXX.cpp | |
| parent | 781797f58652b2306ea72287a5f5ced5cda71a50 (diff) | |
| download | bcm5719-llvm-ae438f8c03a6f7c30f31bc082c3083ee0d0bf1f4.tar.gz bcm5719-llvm-ae438f8c03a6f7c30f31bc082c3083ee0d0bf1f4.zip | |
Check whether a tag was defined in a C++ condition declaration using GetTypeForDeclarator.
llvm-svn: 78644
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index fde61e88562..20f69069a5a 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -747,7 +747,8 @@ Sema::ActOnCXXConditionDeclarationExpr(Scope *S, SourceLocation StartLoc, assert(D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef && "Parser allowed 'typedef' as storage class of condition decl."); - QualType Ty = GetTypeForDeclarator(D, S); + TagDecl *OwnedTag = 0; + QualType Ty = GetTypeForDeclarator(D, S, /*Skip=*/0, &OwnedTag); if (Ty->isFunctionType()) { // The declarator shall not specify a function... // We exit without creating a CXXConditionDeclExpr because a FunctionDecl @@ -757,18 +758,9 @@ Sema::ActOnCXXConditionDeclarationExpr(Scope *S, SourceLocation StartLoc, } else if (Ty->isArrayType()) { // ...or an array. Diag(StartLoc, diag::err_invalid_use_of_array_type) << SourceRange(StartLoc, EqualLoc); - } else if (const RecordType *RT = Ty->getAs<RecordType>()) { - RecordDecl *RD = RT->getDecl(); - // The type-specifier-seq shall not declare a new class... - if (RD->isDefinition() && - (RD->getIdentifier() == 0 || S->isDeclScope(DeclPtrTy::make(RD)))) - Diag(RD->getLocation(), diag::err_type_defined_in_condition); - } else if (const EnumType *ET = Ty->getAsEnumType()) { - EnumDecl *ED = ET->getDecl(); - // ...or enumeration. - if (ED->isDefinition() && - (ED->getIdentifier() == 0 || S->isDeclScope(DeclPtrTy::make(ED)))) - Diag(ED->getLocation(), diag::err_type_defined_in_condition); + } else if (OwnedTag && OwnedTag->isDefinition()) { + // The type-specifier-seq shall not declare a new class or enumeration. + Diag(OwnedTag->getLocation(), diag::err_type_defined_in_condition); } DeclPtrTy Dcl = ActOnDeclarator(S, D); |

