Implement jump checking for initialized c++ variables, implementing
a fixme and PR6451.
Only perform jump checking if the containing function has no errors,
and add the infrastructure needed to do this.
On the testcase in the PR, we produce:
t.cc:6:3: error: illegal goto into protected scope
goto later;
^
t.cc:7:5: note: jump bypasses variable initialization
X x;
^
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97497 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 3072dfe..2d6fd26 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -147,6 +147,10 @@
/// return types, if any, in the block body.
QualType ReturnType;
+ /// SavedNumErrorsAtStartOfFunction - This is the value of the
+ /// NumErrorsAtStartOfFunction variable at the point when the block started.
+ unsigned SavedNumErrorsAtStartOfFunction;
+
/// SavedFunctionNeedsScopeChecking - This is the value of
/// CurFunctionNeedsScopeChecking at the point when the block started.
bool SavedFunctionNeedsScopeChecking;
@@ -241,6 +245,13 @@
/// the current full expression.
llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries;
+ /// NumErrorsAtStartOfFunction - This is the number of errors that were
+ /// emitted to the diagnostics object at the start of the current
+ /// function/method definition. If no additional errors are emitted by the
+ /// end of the function, we assume the AST is well formed enough to be
+ /// worthwhile to emit control flow diagnostics.
+ unsigned NumErrorsAtStartOfFunction;
+
/// CurFunctionNeedsScopeChecking - This is set to true when a function or
/// ObjC method body contains a VLA or an ObjC try block, which introduce
/// scopes that need to be checked for goto conditions. If a function does