summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-01-24 23:09:00 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-01-24 23:09:00 +0000
commit52cc016f2199922f10d7eb9e9bc0229843ab8051 (patch)
tree85dc282e60f986dc22cf4c8efd65a33c1d1585a6 /clang/lib/Sema
parent8549e5dcc868f1c6c75ecd11bd8762a018af9f1d (diff)
downloadbcm5719-llvm-52cc016f2199922f10d7eb9e9bc0229843ab8051.tar.gz
bcm5719-llvm-52cc016f2199922f10d7eb9e9bc0229843ab8051.zip
PR3062: statement expressions should be illegal at file scope. I don't
think this has any significant effects at the moment, but it could matter if we start constant-folding statement expressions like gcc does. llvm-svn: 62943
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d4babb4baa4..1d55ed7c3aa 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3940,6 +3940,11 @@ Sema::ExprResult Sema::ActOnStmtExpr(SourceLocation LPLoc, StmtTy *substmt,
assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!");
CompoundStmt *Compound = cast<CompoundStmt>(SubStmt);
+ bool isFileScope = getCurFunctionOrMethodDecl() == 0;
+ if (isFileScope) {
+ return Diag(LPLoc, diag::err_stmtexpr_file_scope);
+ }
+
// FIXME: there are a variety of strange constraints to enforce here, for
// example, it is not possible to goto into a stmt expression apparently.
// More semantic analysis is needed.
OpenPOWER on IntegriCloud