From 71af1216657cec047a75cb10e04e4447007ce9cd Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 24 Mar 2011 11:39:34 +0900 Subject: [PATCH] Detect missing @end tags. Give a warning when @end is forgotten in class implementations. --- tools/qfcc/source/class.c | 5 +++++ tools/qfcc/source/qc-parse.y | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index b6b6cbafd..3f1f7e67c 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -553,6 +553,11 @@ begin_class (class_t *class) void class_begin (class_type_t *class_type) { + if (current_class) { + warning (0, "‘@end’ missing in implementation context"); + class_finish (current_class); + current_class = 0; + } switch (class_type->type) { case ct_category: begin_category (class_type->c.category); diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index db077799e..a6dabeedc 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -293,6 +293,16 @@ spec_merge (specifier_t spec, specifier_t new) %% +program + : external_def_list + { + if (current_class) { + warning (0, "‘@end’ missing in implementation context"); + class_finish (current_class); + current_class = 0; + } + } + external_def_list : /* empty */ { @@ -1312,6 +1322,11 @@ class_name new_class_name : identifier { + if (current_class) { + warning (0, "‘@end’ missing in implementation context"); + class_finish (current_class); + current_class = 0; + } $$ = get_class ($1, 0); if (!$$) { $1 = check_redefined ($1); @@ -1354,6 +1369,11 @@ category_name new_category_name : identifier '(' identifier ')' { + if (current_class) { + warning (0, "‘@end’ missing in implementation context"); + class_finish (current_class); + current_class = 0; + } $$ = get_category ($1, $3->name, 1); if ($$->defined) { error (0, "redefinition of category `%s (%s)'",