From: Douglas Gregor Date: Wed, 10 Dec 2008 20:57:37 +0000 (+0000) Subject: Some cleanups to the dependent-types commit, as suggested by Sebastian X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=83f96f668d0bcc957ead2032fe6e6c475dc156e5;p=clang Some cleanups to the dependent-types commit, as suggested by Sebastian git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60848 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 241dce6c95..233a661a4c 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1210,7 +1210,6 @@ QualType ASTContext::getCanonicalType(QualType T) { DSAT->getSizeModifier(), DSAT->getIndexTypeQualifier()); - // FIXME: What is the ownership of size expressions in VLAs? VariableArrayType *VAT = cast(AT); return getVariableArrayType(NewEltTy, VAT->getSizeExpr(), VAT->getSizeModifier(), @@ -1283,8 +1282,6 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) { IAT->getSizeModifier(), IAT->getIndexTypeQualifier())); - // FIXME: What is the ownership of size expressions in - // dependent-sized array types? if (const DependentSizedArrayType *DSAT = dyn_cast(ATy)) return cast( @@ -1293,7 +1290,6 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) { DSAT->getSizeModifier(), DSAT->getIndexTypeQualifier())); - // FIXME: What is the ownership of size expressions in VLAs? const VariableArrayType *VAT = cast(ATy); return cast(getVariableArrayType(NewEltTy, VAT->getSizeExpr(), VAT->getSizeModifier(), diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index a2dc7f7c89..a36bcf5880 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -510,48 +510,48 @@ Sema::ExprResult Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // If this reference is not in a block or if the referenced variable is // within the block, create a normal DeclRefExpr. - // C++ [temp.dep.expr]p3: - // An id-expression is type-dependent if it contains: bool TypeDependent = false; - - // - an identifier that was declared with a dependent type, - if (VD->getType()->isDependentType()) - TypeDependent = true; - // - FIXME: a template-id that is dependent, - // - a conversion-function-id that specifies a dependent type, - else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName && - Name.getCXXNameType()->isDependentType()) - TypeDependent = true; - // - a nested-name-specifier that contains a class-name that - // names a dependent type. - else if (SS && !SS->isEmpty()) { - for (DeclContext *DC = static_cast(SS->getScopeRep()); - DC; DC = DC->getParent()) { - // FIXME: could stop early at namespace scope. - if (DC->isCXXRecord()) { - CXXRecordDecl *Record = cast(DC); - if (Context.getTypeDeclType(Record)->isDependentType()) { - TypeDependent = true; - break; + bool ValueDependent = false; + if (getLangOptions().CPlusPlus) { + // C++ [temp.dep.expr]p3: + // An id-expression is type-dependent if it contains: + // - an identifier that was declared with a dependent type, + if (VD->getType()->isDependentType()) + TypeDependent = true; + // - FIXME: a template-id that is dependent, + // - a conversion-function-id that specifies a dependent type, + else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName && + Name.getCXXNameType()->isDependentType()) + TypeDependent = true; + // - a nested-name-specifier that contains a class-name that + // names a dependent type. + else if (SS && !SS->isEmpty()) { + for (DeclContext *DC = static_cast(SS->getScopeRep()); + DC; DC = DC->getParent()) { + // FIXME: could stop early at namespace scope. + if (DC->isCXXRecord()) { + CXXRecordDecl *Record = cast(DC); + if (Context.getTypeDeclType(Record)->isDependentType()) { + TypeDependent = true; + break; + } } } } - } - // C++ [temp.dep.constexpr]p2: - // - // An identifier is value-dependent if it is: - bool ValueDependent = false; - - // - a name declared with a dependent type, - if (TypeDependent) - ValueDependent = true; - // - the name of a non-type template parameter, - else if (isa(VD)) - ValueDependent = true; - // - a constant with integral or enumeration type and is - // initialized with an expression that is value-dependent - // (FIXME!). + // C++ [temp.dep.constexpr]p2: + // + // An identifier is value-dependent if it is: + // - a name declared with a dependent type, + if (TypeDependent) + ValueDependent = true; + // - the name of a non-type template parameter, + else if (isa(VD)) + ValueDependent = true; + // - a constant with integral or enumeration type and is + // initialized with an expression that is value-dependent + // (FIXME!). + } return new DeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc, TypeDependent, ValueDependent);