From d123bd05cab62bb3c641d0c2343fd94e6a96235e Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Sat, 28 Feb 2009 16:48:43 +0000 Subject: Fix problems with labels and blocks. - Move the 'LabelMap' from Sema to Scope. To avoid layering problems, the second element is now a 'StmtTy *', which makes the LabelMap a bit more verbose to deal with. - Add 'ActiveScope' to Sema. Managed by ActOnStartOfFunctionDef(), ObjCActOnStartOfMethodDef(), ActOnBlockStmtExpr(). - Changed ActOnLabelStmt(), ActOnGotoStmt(), ActOnAddrLabel(), and ActOnFinishFunctionBody() to use the new ActiveScope. - Added FIXME to workaround in ActOnFinishFunctionBody() (for dealing with C++ nested functions). llvm-svn: 65694 --- clang/test/Sema/block-labels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 clang/test/Sema/block-labels.c (limited to 'clang/test/Sema/block-labels.c') diff --git a/clang/test/Sema/block-labels.c b/clang/test/Sema/block-labels.c new file mode 100644 index 00000000000..15e6f61cede --- /dev/null +++ b/clang/test/Sema/block-labels.c @@ -0,0 +1,17 @@ +// RUN: clang %s -verify -fblocks -fsyntax-only + +int a() { + A:if (1) xx(); + return ^{A:return 1;}(); +} +int b() { + A: return ^{int a; A:return 1;}(); +} + +int d() { + A: return ^{int a; A: a = ^{int a; A:return 1;}() + ^{int b; A:return 2;}(); return a; }(); +} + +int c() { + goto A; return ^{ A:return 1;}(); // expected-error {{use of undeclared label 'A'}} +} -- cgit v1.2.3