diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/.traces/convert_names_warns | 11 | ||||
-rw-r--r-- | cpp/002trace | 2 | ||||
-rw-r--r-- | cpp/025name | 10 |
3 files changed, 20 insertions, 3 deletions
diff --git a/cpp/.traces/convert_names_warns b/cpp/.traces/convert_names_warns new file mode 100644 index 00000000..837f83df --- /dev/null +++ b/cpp/.traces/convert_names_warns @@ -0,0 +1,11 @@ +parse/0: instruction: 1 +parse/0: ingredient: {name: "y", value: 0, type: 1, properties: ["y": "integer"]} +parse/0: product: {name: "x", value: 0, type: 1, properties: ["x": "integer"]} +warn/0: use before set: y in main +name/0: assign x 1 +after-brace/0: recipe main +after-brace/0: copy ... +run/0: instruction main/0 +run/0: ingredient 0 is y +mem/0: location 0 is 0 +mem/0: storing 0 in location 1 diff --git a/cpp/002trace b/cpp/002trace index cd3498b4..4946517c 100644 --- a/cpp/002trace +++ b/cpp/002trace @@ -160,7 +160,7 @@ trace_stream* Trace_stream = NULL; #define trace(layer) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(layer) // Warnings should go straight to cerr by default since calls to trace() have // some unfriendly constraints (they delay printing, they can't nest) -#define raise ((!Trace_stream || !Hide_warnings) ? cerr /*do print*/ : Trace_stream->stream("warn")) << __FILE__ << ":" << __LINE__ << " " +#define raise ((!Trace_stream || !Hide_warnings) ? cerr /*do print*/ : Trace_stream->stream("warn")) // A separate helper for debugging. We should only trace domain-specific // facts. For everything else use log. diff --git a/cpp/025name b/cpp/025name index f5ab234d..78250426 100644 --- a/cpp/025name +++ b/cpp/025name @@ -11,6 +11,13 @@ recipe main [ +run: instruction main/0 +mem: storing 0 in location 1 +:(scenario "convert_names_warns") +hide warnings +recipe main [ + x:integer <- copy y:integer +] ++warn: use before set: y in main + :(after "int main") Transform.push_back(transform_names); @@ -39,8 +46,7 @@ void transform_names(const recipe_number r) { && inst.ingredients[in].types[0] && inst.ingredients[in].name.find_first_not_of("0123456789-.") != string::npos) { if (names.find(inst.ingredients[in].name) == names.end()) { - // todo: test - cerr << "user before set: " << inst.ingredients[in].name << " in " << Recipe[r].name << '\n'; + raise << "use before set: " << inst.ingredients[in].name << " in " << Recipe[r].name; } inst.ingredients[in].set_value(names[inst.ingredients[in].name]); } |