aboutsummaryrefslogtreecommitdiff
path: root/gcc/cobol/show_parse.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cobol/show_parse.h')
-rw-r--r--gcc/cobol/show_parse.h106
1 files changed, 74 insertions, 32 deletions
diff --git a/gcc/cobol/show_parse.h b/gcc/cobol/show_parse.h
index f7ab982..bd0e16f 100644
--- a/gcc/cobol/show_parse.h
+++ b/gcc/cobol/show_parse.h
@@ -147,10 +147,10 @@ extern bool cursor_at_sol;
fprintf(stderr, "<%s>", cbl_field_type_str((b).field->type)); \
} \
} \
- if( (b).nsubscript) \
+ if( (b).nsubscript()) \
{ \
fprintf(stderr,"("); \
- for(size_t jjj=0; jjj<(b).nsubscript; jjj++) \
+ for(size_t jjj=0; jjj<(b).nsubscript(); jjj++) \
{ \
if(jjj) \
{ \
@@ -176,11 +176,21 @@ extern bool cursor_at_sol;
} \
else \
{ \
- fprintf(stderr, " %p:%s (%s)", (void*)b, b->name, b->type_str()); \
+ fprintf(stderr, " %p:%s (%s)", static_cast<void*>(b), b->name, b->type_str()); \
} \
show_parse_sol = false; \
} while(0);
+// Use this version when b is known to be valid. This is necessary to quiet
+// cppcheck nullPointerRedundantCheck warnings
+#define SHOW_PARSE_LABEL_OK(a, b) \
+ do \
+ { \
+ fprintf(stderr, "%s", a); \
+ fprintf(stderr, " %p:%s (%s)", static_cast<void*>(b), b->name, b->type_str()); \
+ show_parse_sol = false; \
+ } while(0);
+
#define TRACE1 if(bTRACE1)
#define TRACE1_HEADER do \
{ \
@@ -211,6 +221,7 @@ extern bool cursor_at_sol;
#define TRACE1_FIELD_VALUE(a, field, b) \
do \
{ \
+ gcc_assert(field); \
cursor_at_sol=false; \
if ( field->type == FldConditional ) \
{ \
@@ -337,13 +348,13 @@ extern bool cursor_at_sol;
else \
{ \
gg_fprintf(trace_handle, 1, "%s", gg_string_literal( (b).field->name ? (b).field->name:"")); \
- if( b.nsubscript ) \
+ if( b.nsubscript() ) \
{ \
gg_fprintf(trace_handle, 0, "("); \
- for(unsigned int i=0; i<b.nsubscript; i++) \
+ for(unsigned int i=0; i<b.nsubscript(); i++) \
{ \
gg_fprintf(trace_handle, 1, "%s", gg_string_literal( b.subscripts[i].field->name ? b.subscripts[i].field->name : "" )); \
- if( i<b.nsubscript-1 ) \
+ if( i<b.nsubscript()-1 ) \
{ \
gg_fprintf(trace_handle, 0, " "); \
} \
@@ -423,31 +434,61 @@ extern bool cursor_at_sol;
} while(0);
// Use CHECK_FIELD when a should be non-null, and a->var_decl_node also should
-// by non-null:
-#define CHECK_FIELD(a) \
- do{ \
- if(!a) \
- { \
- yywarn("%s(): parameter " #a " is NULL", __func__); \
- gcc_unreachable(); \
- } \
- if( !a->var_decl_node && a->type != FldConditional && a->type != FldLiteralA) \
- { \
- yywarn("%s() parameter " #a " is variable %s<%s> with NULL var_decl_node", \
- __func__, \
- a->name, \
- cbl_field_type_str(a->type) ); \
- gcc_unreachable(); \
- } \
- }while(0);
-
-#define CHECK_LABEL(a) \
- do{ \
- if(!a) \
- { \
- yywarn("%s(): parameter " #a " is NULL", __func__); \
- gcc_unreachable(); \
- } \
+// by non-null. (The useless calls to abort() are because cppcheck doesn't
+// understand that gcc_unreachable doesn't return);
+
+// Use this after doing any SHOW_PARSE stuff, to avoid cppcheck complaints
+// about nullPointerRedundantCheck
+#define CHECK_FIELD(a) \
+ do { \
+ if(!a) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is NULL", __func__); \
+ gcc_unreachable(); \
+ abort(); \
+ } \
+ if( !a->var_decl_node ) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is variable " \
+ "%s<%s> with NULL %<var_decl_node%>", \
+ __func__, \
+ a->name, \
+ cbl_field_type_str(a->type) ); \
+ gcc_unreachable(); \
+ abort(); \
+ } \
+ } while(0);
+
+// This version is a bit more lax, for special cases
+#define CHECK_FIELD2(a) \
+ do { \
+ if(!a) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is NULL", __func__); \
+ gcc_unreachable(); \
+ abort(); \
+ } \
+ if( !a->var_decl_node && a->type != FldConditional && a->type != FldLiteralA) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is variable " \
+ "%s<%s> with NULL %<var_decl_node%>", \
+ __func__, \
+ a->name, \
+ cbl_field_type_str(a->type) ); \
+ gcc_unreachable(); \
+ abort(); \
+ } \
+ } while(0);
+
+
+#define CHECK_LABEL(a) \
+ do{ \
+ if(!a) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is NULL", __func__); \
+ gcc_unreachable(); \
+ abort(); \
+ } \
}while(0);
#ifdef INCORPORATE_ANALYZER
@@ -503,10 +544,11 @@ class ANALYZE
}
};
#else
+// cppcheck-suppress ctuOneDefinitionRuleViolation
class ANALYZE
{
public:
- ANALYZE(const char *)
+ explicit ANALYZE(const char *)
{
}
~ANALYZE()