[cfe-commits] r60615 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Expr.h include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/AST/CFG.cpp lib/AST/Expr.cpp lib/AST/StmtIterator.cpp lib/AST/Type.cpp lib/AST/TypeSerialization.cpp lib/CodeGen/CodeGenTypes.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaStmt.cpp lib/Sema/SemaTemplate.cpp lib/Sema/SemaType.cpp test/SemaCXX/dependent-types.cpp test/SemaCXX/type-dependent-exprs.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sat Dec 6 04:35:39 PST 2008
Douglas Gregor wrote:
> Author: dgregor
> Date: Fri Dec 5 17:32:09 2008
> New Revision: 60615
>
> URL: http://llvm.org/viewvc/llvm-project?rev=60615&view=rev
> Log:
> Introduce basic support for dependent types, type-dependent
> expressions, and value-dependent expressions. This permits us to parse
> some template definitions.
>
Yay!
> +/// getDependentSizedArrayType - Returns a non-unique reference to
> +/// the type for a dependently-sized array of the specified element
> +/// type. FIXME: We will need these to be uniqued, or at least
> +/// comparable, at some point.
>
Do VLAs have the same FIXME? Why do we need this?
> // FIXME: What is the ownership of size expressions in VLAs?
> VariableArrayType *VAT = cast<VariableArrayType>(AT);
> return getVariableArrayType(NewEltTy, VAT->getSizeExpr(),
> @@ -1246,6 +1282,16 @@
> return cast<ArrayType>(getIncompleteArrayType(NewEltTy,
> IAT->getSizeModifier(),
> IAT->getIndexTypeQualifier()));
> +
> + // FIXME: What is the ownership of size expressions in
> + // dependent-sized array types?
> + if (const DependentSizedArrayType *DSAT
> + = dyn_cast<DependentSizedArrayType>(ATy))
> + return cast<ArrayType>(
> + getDependentSizedArrayType(NewEltTy,
> + DSAT->getSizeExpr(),
> + DSAT->getSizeModifier(),
> + DSAT->getIndexTypeQualifier()));
>
VLAs destroy their size expression when they die, so they seem to assume
ownership. Why is this still a FIXME?
>
> +// FIXME: Add support for dependent-sized array types in C++?
> +// Does it even make sense to build a CFG for an uninstantiated template?
>
I'd say no.
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Dec 5 17:32:09 2008
> @@ -490,7 +490,52 @@
> }
> // If this reference is not in a block or if the referenced variable is
> // within the block, create a normal DeclRefExpr.
> - return new DeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc);
> +
> + // C++ [temp.dep.expr]p3:
> + // An id-expression is type-dependent if it contains:
> + bool TypeDependent = false;
>
I expect the C guys will want this entire block in an if (CPlusPlus).
>
> // first, check the condition.
> - if (!condT->isScalarType()) { // C99 6.5.15p2
> - Diag(cond->getLocStart(), diag::err_typecheck_cond_expect_scalar) << condT;
> - return QualType();
> + if (!cond->isTypeDependent()) {
> + if (!condT->isScalarType()) { // C99 6.5.15p2
> + Diag(cond->getLocStart(), diag::err_typecheck_cond_expect_scalar) << condT;
> + return QualType();
> + }
> }
>
Merge the ifs?
> Added: cfe/trunk/test/SemaCXX/dependent-types.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dependent-types.cpp?rev=60615&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/dependent-types.cpp (added)
> +++ cfe/trunk/test/SemaCXX/dependent-types.cpp Fri Dec 5 17:32:09 2008
>
I expect we'll get so many template test cases that we should make a
SemaTemplate directory to hold those tests.
Great work, Doug.
Sebastian
More information about the cfe-commits
mailing list