From b00bdd3748c45eb718be72b537d3d9515556d13b Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 17 Nov 2016 14:42:30 +0100 Subject: [PATCH 1/2] C++: PrintAbsyn::render now uses 'const char*' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling BNFC generated code with clang triggers the warning `ISO C++ forbids converting a string constant to ‘char*’` (see -Wwrite-strings) when calling the render function with a string literal like this `render("return");`. This commit fixes this by adding the missing qualifier. --- source/src/BNFC/Backend/CPP/PrettyPrinter.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/src/BNFC/Backend/CPP/PrettyPrinter.hs b/source/src/BNFC/Backend/CPP/PrettyPrinter.hs index 6716c2c84..d09fa043b 100644 --- a/source/src/BNFC/Backend/CPP/PrettyPrinter.hs +++ b/source/src/BNFC/Backend/CPP/PrettyPrinter.hs @@ -83,7 +83,7 @@ mkHFile useStl inPackage cf groups = unlines " /* You may wish to change them */", " void render(Char c);", " void render(String s);", - if useStl then "void render(char *s);" else "", + if useStl then "void render(const char *s);" else "", " void indent(void);", " void backup(void);", " public:", @@ -711,7 +711,7 @@ prRender useStl = unlines [ "bufAppend(s);" , "bufAppend(' ');" ] ] in if useStl then render renderString else "", - "void PrintAbsyn::render(char *s)", + "void PrintAbsyn::render(const char *s)", "{", " if(strlen(s) > 0)", " {", From e8107a065a2b00ee8fb362886d99416026eb14b1 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Sat, 19 Nov 2016 16:14:58 +0100 Subject: [PATCH 2/2] Fixed cpp-nostl compilation error --- source/src/BNFC/Backend/CPP/PrettyPrinter.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/src/BNFC/Backend/CPP/PrettyPrinter.hs b/source/src/BNFC/Backend/CPP/PrettyPrinter.hs index d09fa043b..575b32b27 100644 --- a/source/src/BNFC/Backend/CPP/PrettyPrinter.hs +++ b/source/src/BNFC/Backend/CPP/PrettyPrinter.hs @@ -82,8 +82,8 @@ mkHFile useStl inPackage cf groups = unlines " /* The following are simple heuristics for rendering terminals */", " /* You may wish to change them */", " void render(Char c);", - " void render(String s);", - if useStl then "void render(const char *s);" else "", + if useStl then " void render(String s);" else "", + "void render(const char *s);", " void indent(void);", " void backup(void);", " public:",