summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@gmail.com>2012-01-07 10:52:36 +0000
committerAbramo Bagnara <abramo.bagnara@gmail.com>2012-01-07 10:52:36 +0000
commit1cd8368eb2559035adadc83f66101df13becf4a9 (patch)
tree5d5226559de814872af5fc225083f8f3416189de /clang
parente57e752b71f0254e697156ed8c5c15040f53e6d6 (diff)
downloadbcm5719-llvm-1cd8368eb2559035adadc83f66101df13becf4a9.tar.gz
bcm5719-llvm-1cd8368eb2559035adadc83f66101df13becf4a9.zip
Fixed TypeofExpr AST and code generation.
llvm-svn: 147730
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Sema/Sema.h2
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp24
-rw-r--r--clang/lib/Parse/ParseDecl.cpp5
-rw-r--r--clang/lib/Sema/SemaDecl.cpp19
-rw-r--r--clang/test/CodeGen/vla.c3
5 files changed, 20 insertions, 33 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 389cf8ac72f..b686d2dd439 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1146,8 +1146,6 @@ public:
DeclSpec &DS,
MultiTemplateParamsArg TemplateParams);
- StmtResult ActOnVlaStmt(const DeclSpec &DS);
-
Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
AccessSpecifier AS,
RecordDecl *Record);
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 62d18ea8eed..cde2de9819a 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -929,19 +929,33 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
// We're going to walk down into the type and look for VLA
// expressions.
- type = type.getCanonicalType();
do {
assert(type->isVariablyModifiedType());
const Type *ty = type.getTypePtr();
switch (ty->getTypeClass()) {
+
+ default:
+ // Only sugared types (different from typeof_expr) can reach this point.
+ assert(!type.isCanonical() && "unhandled canonical type!");
+ type = type.getSingleStepDesugaredType(getContext());
+ break;
+
+ case Type::TypeOfExpr: {
+ // This is the only sugared type requiring special treatment.
+ // Emit typeof expression and we are done.
+ Expr *E = cast<TypeOfExprType>(ty)->getUnderlyingExpr();
+ EmitIgnoredExpr(E);
+ return;
+ }
+
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
-#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
+#define NON_CANONICAL_TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base) case Type::Class:
-#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
+#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
#include "clang/AST/TypeNodes.def"
- llvm_unreachable("unexpected dependent or non-canonical type!");
+ llvm_unreachable("unexpected dependent type!");
// These types are never variably-modified.
case Type::Builtin:
@@ -999,7 +1013,7 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
break;
}
- case Type::FunctionProto:
+ case Type::FunctionProto:
case Type::FunctionNoProto:
type = cast<FunctionType>(ty)->getResultType();
break;
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ee4a51e184a..16321491ee8 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -962,10 +962,7 @@ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(StmtVector &Stmts,
ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS_none,
getDeclSpecContextFromDeclaratorContext(Context));
- StmtResult R = Actions.ActOnVlaStmt(DS);
- if (R.isUsable())
- Stmts.push_back(R.release());
-
+
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
if (Tok.is(tok::semi)) {
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d1bf3db19ca..d80f22f7fe7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2481,25 +2481,6 @@ 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.
///
diff --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c
index c9612bc1603..9e62da52e02 100644
--- a/clang/test/CodeGen/vla.c
+++ b/clang/test/CodeGen/vla.c
@@ -116,9 +116,6 @@ int test4(unsigned n, char (*p)[n][n+1][6]) {
// CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4
// CHECK-NEXT: [[DIM1:%.*]] = add i32 [[T0]], 1
- // __typeof. FIXME: does this really need to be loaded?
- // CHECK-NEXT: load [6 x i8]** [[P]]
-
// CHECK-NEXT: [[T0:%.*]] = load [6 x i8]** [[P]], align 4
// CHECK-NEXT: [[T1:%.*]] = load i32* [[N]], align 4
// CHECK-NEXT: [[T2:%.*]] = udiv i32 [[T1]], 2
OpenPOWER on IntegriCloud