Просмотр исходного кода

Merge pull request #9168 from ghalliday/issue15993

HPCC-15993 Prevent embedded c++ from reporting other warnings as errors

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 лет назад
Родитель
Сommit
f8107342ee

+ 2 - 0
ecl/hqlcpp/hqlcatom.cpp

@@ -94,6 +94,7 @@ IAtom * _spillReason_Atom;
 IAtom * _steppedMeta_Atom;
 IAtom * subgraphAtom;
 IAtom * _translated_Atom;
+IAtom * userFunctionAtom;
 IAtom * utf8Atom;
 IAtom * wrapperAtom;
 IAtom * xmlColumnProviderAtom;
@@ -1481,6 +1482,7 @@ MODULE_INIT(INIT_PRIORITY_HQLATOM-1)
     MAKEATOM(skipReturnMarker);
     MAKEATOM(speed);
     MAKEATOM(subgraph);
+    MAKEATOM(userFunction);
     utf8Atom = createAtom("utf-8");
     MAKEATOM(wrapper);
     MAKEATOM(xmlColumnProvider);

+ 1 - 0
ecl/hqlcpp/hqlcatom.hpp

@@ -94,6 +94,7 @@ extern IAtom * _spillReason_Atom;
 extern IAtom * _steppedMeta_Atom;
 extern IAtom * subgraphAtom;
 extern IAtom * _translated_Atom;
+extern IAtom * userFunctionAtom;
 extern IAtom * utf8Atom;
 extern IAtom * wrapperAtom;
 extern IAtom * xmlColumnProviderAtom;

+ 17 - 7
ecl/hqlcpp/hqlcpp.cpp

@@ -1790,7 +1790,7 @@ void HqlCppTranslator::cacheOptions()
         DebugOption(options.optimizeSortAllFieldsStrict,"optimizeSortAllFieldsStrict",false),
         DebugOption(options.alwaysReuseGlobalSpills,"alwaysReuseGlobalSpills",true),
         DebugOption(options.forceAllDatasetsParallel,"forceAllDatasetsParallel",false),  // Purely for regression testing.
-        DebugOption(options.embeddedWarningsAsErrors,"embeddedWarningsAsErrors",true),
+        DebugOption(options.embeddedWarningsAsErrors,"embeddedWarningsFatal",true),
         DebugOption(options.optimizeCriticalFunctions,"optimizeCriticalFunctions",true),
         DebugOption(options.addLikelihoodToGraph,"addLikelihoodToGraph", true),
     };
@@ -11740,8 +11740,10 @@ void HqlCppTranslator::buildCppFunctionDefinition(BuildCtx &funcctx, IHqlExpress
         startLine += memcount(body-start, start, '\n');
     }
 
+    bool addPragmas = options.embeddedWarningsAsErrors && !bodyCode->hasAttribute(inlineAtom);
+
     BuildCtx outerctx(funcctx);
-    if (options.embeddedWarningsAsErrors)
+    if (addPragmas)
     {
         funcctx.addQuoted("#if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))\n"
                 "#pragma GCC diagnostic error \"-Wall\"\n"
@@ -11752,7 +11754,7 @@ void HqlCppTranslator::buildCppFunctionDefinition(BuildCtx &funcctx, IHqlExpress
 
     funcctx.addQuotedCompound(proto);
 
-    if (options.embeddedWarningsAsErrors)
+    if (addPragmas)
     {
         outerctx.addQuoted("\n#if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))\n"
                 "#pragma GCC diagnostic ignored \"-Wall\"\n"
@@ -12046,13 +12048,21 @@ void HqlCppTranslator::buildFunctionDefinition(IHqlExpression * funcdef)
         else
         {
             bool isInline = bodyCode->hasAttribute(inlineAtom);
-            if (isInline && options.spanMultipleCpp)
+            if (isInline)
             {
-                BuildCtx funcctx2(*code, parentHelpersAtom);
-                buildCppFunctionDefinition(funcctx2, bodyCode, proto);
+                if (options.spanMultipleCpp)
+                {
+                    BuildCtx funcctx2(*code, parentHelpersAtom);
+                    buildCppFunctionDefinition(funcctx2, bodyCode, proto);
+                }
+                else
+                    buildCppFunctionDefinition(funcctx, bodyCode, proto);
             }
             else
-                buildCppFunctionDefinition(funcctx, bodyCode, proto);
+            {
+                BuildCtx funcctx2(*code, userFunctionAtom);
+                buildCppFunctionDefinition(funcctx2, bodyCode, proto);
+            }
         }
     }
     else

+ 2 - 2
ecl/hqlcpp/hqlwcpp.cpp

@@ -594,7 +594,7 @@ bool HqlCppWriter::generateFunctionPrototype(IHqlExpression * funcdef, const cha
         throwError(HQLERR_ServiceDefinitionNotAllowed);
 
     if (body->hasAttribute(includeAtom) || body->hasAttribute(ctxmethodAtom) || body->hasAttribute(gctxmethodAtom) || body->hasAttribute(methodAtom)
-        || body->hasAttribute(sysAtom) || body->hasAttribute(omethodAtom) || body->hasAttribute(inlineAtom) )
+        || body->hasAttribute(sysAtom) || body->hasAttribute(omethodAtom))
         return false;
 
     IHqlExpression *proto = body->queryAttribute(prototypeAtom);
@@ -610,7 +610,7 @@ bool HqlCppWriter::generateFunctionPrototype(IHqlExpression * funcdef, const cha
     bool isLocal = body->hasAttribute(localAtom);
 
     IHqlExpression *child = body->queryChild(0);
-    bool isInline = child?child->hasAttribute(inlineAtom):false;
+    bool isInline = body->hasAttribute(inlineAtom) || (child && child->hasAttribute(inlineAtom));
 
     if (body->hasAttribute(eclrtlAtom))
         api = RtlApi;

+ 2 - 3
ecl/regress/cppbody3.ecl

@@ -51,10 +51,9 @@ output(s1fp);
 
 export dummy2 := 1;
 
-real8 s1f(real a) :=
-BEGINC++
+real8 s1f(real a) := EMBED(C++ : inline)
 return sqrt(a);
-ENDC++;
+ENDEMBED;
 s1fp := s1f(3) : persist('s2f');
 output(s1fp);
 

+ 2 - 2
ecl/regress/cpptransform1.ecl

@@ -32,9 +32,9 @@ outRecord := RECORD
 STRING30    fullname;
              END;
 
-transform(outRecord) createName(namesRecord l) := BEGINC++
+transform(outRecord) createName(namesRecord l) := EMBED(C++ : inline)
     memcpy(__self.getSelf(), l, 30);
     return 30;
-ENDC++;
+ENDEMBED;
 
 output(project(namesTable2, createName(LEFT)));

+ 1 - 0
rtl/ecltpl/childtpl.cpp

@@ -27,3 +27,4 @@ $?$/* Template for generating a child module for query */
 #include "$headerName$"
 
 @helper@
+@userFunction@

+ 1 - 0
rtl/ecltpl/thortpl.cpp

@@ -36,3 +36,4 @@ extern "C" ECL_API IEclProcess* createProcess()
     return new MyEclProcess;
 }
 
+@userFunction@