aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-09-28 20:42:35 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-09-28 20:42:35 +0000
commitc5be7b0fc804d8e6f87298ec03c94d8cccd74f29 (patch)
tree58e08f5b9acae774be52b0421a073a673a291ab1 /lib/Sema/SemaDecl.cpp
parent2cf9d656f6283f2a8be0549da110d7cfbb1ea4b2 (diff)
vla expressions used in __typeof__ must be evaluated.
Fixes rdar://8476159. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114982 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index e6e4420f23..544d9842c1 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1691,6 +1691,25 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
return TagD;
}
+/// ActOnVlaStmt - This rouine if finds a vla expression in a decl spec.
+/// builds a statement for it and returns it so it is evaluated.
+StmtResult Sema::ActOnVlaStmt(const DeclSpec &DS) {
+ StmtResult R;
+ if (DS.getTypeSpecType() == DeclSpec::TST_typeofExpr) {
+ Expr *Exp = DS.getRepAsExpr();
+ QualType Ty = Exp->getType();
+ if (Ty->isPointerType()) {
+ do
+ Ty = Ty->getAs<PointerType>()->getPointeeType();
+ while (Ty->isPointerType());
+ }
+ if (Ty->isVariableArrayType()) {
+ R = ActOnExprStmt(MakeFullExpr(Exp));
+ }
+ }
+ return R;
+}
+
/// We are trying to inject an anonymous member into the given scope;
/// check if there's an existing declaration that can't be overloaded.
///