Skip to content
Permalink
Browse files

Code cleanup for dinit.c, dinit.h, errmsg.cpp, semant.h.

Add #if guards, use LLVM coding stadards, use bool, etc.
Remove unneeded function declarations.
  • Loading branch information...
mleair committed May 3, 2018
1 parent 36c5b3a commit 7fe06279c04f465a1b3d136e304162e1171fa799
Showing with 73 additions and 15 deletions.
  1. +1 −6 tools/flang2/flang2exe/dinit.c
  2. +57 −2 tools/flang2/flang2exe/dinit.h
  3. +0 −1 tools/flang2/flang2exe/semant.h
  4. +15 −6 utils/errmsg/errmsg.cpp
@@ -20,14 +20,9 @@
* semant.
*/

#include "gbldefs.h"
#include "error.h"
#include "global.h"
#include "semant.h"
#include "symtab.h"
#include "dinit.h"
#include "ilm.h"
#include "ilmtp.h"
#include "dinit.h"
#include "machardf.h"

/** \brief Effective address of a reference being initialized */
@@ -15,10 +15,19 @@
*
*/

#ifndef DINIT_H_
#define DINIT_H_

/** \file
* \brief (Fortran) declarations needed to use dinitutil.c module.
*/

#include "gbldefs.h"
#include "error.h"
#include "global.h"
#include "semant.h"
#include "symtab.h"

typedef struct {/* dinit file record */
int dtype; /* also sptr */
ISZ_T conval; /* also offset */
@@ -51,6 +60,10 @@ typedef struct {/* dinit file record */
#define DINIT_FUNCCOUNT -31 /* gbl.func_count value */
#define DINIT_STRING -30 /* holds string initialization, length given */

#ifdef __cplusplus
#include "dinitutl.h"
#include "ilmutil.h"
#else
void dinit_init(void);
void dinit_put(int, ISZ_T);
DREC *dinit_read(void);
@@ -62,9 +75,51 @@ void dinit_save(void);
void dinit_restore(void);
long dinit_ftell(void);
void dinit_end(void);
void do_dinit(void);
void dinit_save(void);
void dinit_restore(void);
bool dinit_ok(int);
void dmpilms(void);
void dumpilms(void);
#endif

/**
\brief ...
*/
bool dinit_ok(int sptr);

/**
\brief ...
*/
int mk_largest_val(DTYPE dtype);

/**
\brief ...
*/
int mk_smallest_val(DTYPE dtype);

/**
\brief ...
*/
int mk_unop(int optype, int lop, DTYPE dtype);

/**
\brief ...
*/
void dinit(VAR *ivl, CONST *ict);

/**
\brief ...
*/
void dmp_ict(CONST *ict, FILE *f);

/**
\brief ...
*/
void dmp_ivl(VAR *ivl, FILE *f);

/**
\brief ...
*/
void do_dinit(void);


#endif
@@ -777,7 +777,6 @@ extern void chk_adjarr(), gen_arrdsc(); /* semutil2.c: */
extern int mk_arrdsc();
extern void gen_allocate(int, int, int);
extern void gen_deallocate(int, int);
extern int sem_strcmp(char *, char *);
extern void sem_set_storage_class(int);
extern int enter_lexical_block(int);
extern void exit_lexical_block(int);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -511,9 +511,12 @@ class Errmsg
<< "\n";
return 1;
}
out << "/* This file written by utility program errmsg. Do not modify. "
"*/\n";
out << "#ifdef ERRMSG_GET_ERRTXT_TABLE\nstatic char *errtxt[] = {\n";
out << "// This file written by utility program errmsg. Do not modify.\n"
"#ifdef ERRMSG_GET_ERRTXT_TABLE\n"
"#ifndef ERRMSGDFa_H_\n"
"#define ERRMSGDFa_H_\n"
"static char *errtxt[] = {\n";

out << std::setfill('0');
for (std::vector<Message>::size_type num = 0; num < messages.size();
++num) {
@@ -523,7 +526,11 @@ class Errmsg
else
out << " \"" << messages[num].message << "\",\n";
}
out << "};\n#else /* ERRMSG_GET_ERRTXT_TABLE */\n";
out << "};\n"
"#endif // ERRMSGDFa_H_\n"
"#else /* ERRMSG_GET_ERRTXT_TABLE */\n"
"#ifndef ERRMSGDFb_H_\n"
"#define ERRMSGDFb_H_\n";
// emit an enumeration of all the symbolic error codes.
out << "enum error_code {\n";
for (std::vector<Message>::iterator m = messages.begin();
@@ -535,7 +542,9 @@ class Errmsg
out << " // " << *it << "\n";
}
}
out << "};\n#endif /* ERRMSG_GET_ERRTXT_TABLE */\n";
out << "};\n"
"#endif // ERRMSGDFb_H_\n"
"#endif /* ERRMSG_GET_ERRTXT_TABLE */\n";
return 0;
}
};

0 comments on commit 7fe0627

Please sign in to comment.
You can’t perform that action at this time.