From dc09d46bf4d4ad823307505ff0e2e5de27654540 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 3 Apr 2012 05:36:21 -0700 Subject: [PATCH] Don't emit type declarations for extern'ed globals in generated header files. This actually wasn't a good idea, since we'd like ispc programs to be able to have varying globals that it uses internally among ispc code, without having errors about varying globals when generating headers. Issue #214. --- module.cpp | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/module.cpp b/module.cpp index c7b2a424..c7725b2f 100644 --- a/module.cpp +++ b/module.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2010-2011, Intel Corporation + Copyright (c) 2010-2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -1027,21 +1027,6 @@ lPrintFunctionDeclarations(FILE *file, const std::vector &funcs) { } -static void -lPrintExternGlobals(FILE *file, const std::vector &externGlobals) { - for (unsigned int i = 0; i < externGlobals.size(); ++i) { - Symbol *sym = externGlobals[i]; - if (lRecursiveCheckValidParamType(sym->type)) - Warning(sym->pos, "Not emitting declaration for symbol \"%s\" into " - "generated header file since it (or some of its members) " - "has types that are illegal in exported symbols.", - sym->name.c_str()); - else - fprintf(file, "extern %s;\n", sym->type->GetCDeclaration(sym->name).c_str()); - } -} - - static bool lIsExported(const Symbol *sym) { const FunctionType *ft = dynamic_cast(sym->type); @@ -1058,12 +1043,6 @@ lIsExternC(const Symbol *sym) { } -static bool -lIsExternGlobal(const Symbol *sym) { - return sym->storageClass == SC_EXTERN || sym->storageClass == SC_EXTERN_C; -} - - bool Module::writeHeader(const char *fn) { FILE *f = fopen(fn, "w"); @@ -1116,13 +1095,6 @@ Module::writeHeader(const char *fn) { lGetExportedParamTypes(externCFuncs, &exportedStructTypes, &exportedEnumTypes, &exportedVectorTypes); - // And do the same for the 'extern' globals - std::vector externGlobals; - symbolTable->GetMatchingVariables(lIsExternGlobal, &externGlobals); - for (unsigned int i = 0; i < externGlobals.size(); ++i) - lGetExportedTypes(externGlobals[i]->type, &exportedStructTypes, - &exportedEnumTypes, &exportedVectorTypes); - // And print them lEmitVectorTypedefs(exportedVectorTypes, f); lEmitEnumDecls(exportedEnumTypes, f); @@ -1149,15 +1121,6 @@ Module::writeHeader(const char *fn) { // end namespace fprintf(f, "\n#ifdef __cplusplus\n}\n#endif // __cplusplus\n"); - // and only now emit externs for globals, outside of the ispc namespace - if (externGlobals.size() > 0) { - fprintf(f, "\n"); - fprintf(f, "///////////////////////////////////////////////////////////////////////////\n"); - fprintf(f, "// Globals declared \"extern\" from ispc code\n"); - fprintf(f, "///////////////////////////////////////////////////////////////////////////\n"); - lPrintExternGlobals(f, externGlobals); - } - // end guard fprintf(f, "\n#endif // %s\n", guard.c_str());