[cfe-commits] r78644 - /cfe/trunk/lib/Sema/SemaExprCXX.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Mon Aug 10 22:20:41 PDT 2009


Author: akirtzidis
Date: Tue Aug 11 00:20:41 2009
New Revision: 78644

URL: http://llvm.org/viewvc/llvm-project?rev=78644&view=rev
Log:
Check whether a tag was defined in a C++ condition declaration using GetTypeForDeclarator.

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=78644&r1=78643&r2=78644&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug 11 00:20:41 2009
@@ -747,7 +747,8 @@
   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 @@
   } 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);





More information about the cfe-commits mailing list