Files
carbon-lang/explorer/testdata/unformed/dynamic/fail_pattern_declare.carbon
T
Zenong ZhangandJon Ross-Perkins b28fd7ebc9 Implement more flows on unformed static analysis (#1923)
- Added detection of unformed usage with `return var`, control-flow statements and member access.
- Refactored the work flow: made flow facts a class and moved operations of flow facts into the class.
- Added, cleaned and renamed test cases. Some test cases for the dynamic unformed check were suppressed by the static check. They are now added back.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2022-08-15 10:53:42 -07:00

23 lines
861 B
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s
package ExplorerTest api;
fn Main() -> i32 {
var (x: i32, y: i32);
x = 1;
if (0 == 1) {
y = 0;
}
// Static analysis thinks `y` may be formed, defer the check to run-time.
// CHECK: RUNTIME ERROR: {{.*}}/explorer/testdata/unformed/dynamic/fail_pattern_declare.carbon:[[@LINE+1]]: undefined behavior: access to uninitialized value Uninit<Placeholder<y>>
return y;
}