]> granicus.if.org Git - re2c/commitdiff
Don't output generated code when failed with -Werror.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 27 Jul 2015 10:41:23 +0000 (11:41 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 27 Jul 2015 10:41:23 +0000 (11:41 +0100)
re2c/src/codegen/output.cc
re2c/src/conf/warn.cc
re2c/src/conf/warn.h
re2c/src/main.cc

index b2461531b0abd0a0475b16e8e490f698c9d007d5..520e62b7b79b8c4447777d7dd5b005ddd566a294 100644 (file)
@@ -336,8 +336,11 @@ Output::Output (const char * source_name, const char * header_name)
 
 Output::~Output ()
 {
-       source.emit (types, max_fill);
-       header.emit (types);
+       if (!warn.error ())
+       {
+               source.emit (types, max_fill);
+               header.emit (types);
+       }
 }
 
 void output_state_goto_sub (std::ostream & o, uint32_t ind, uint32_t start_label, int cMin, int cMax)
index 6bd045f6c674731d07792ac16cf7e21798d13c61..01c2fee9e22c1dbf43062e4f2c64ed58bef1d927 100644 (file)
@@ -22,7 +22,7 @@ const char * Warn::names [TYPES] =
 
 Warn::Warn ()
        : mask ()
-       , error (false)
+       , error_accuml (false)
 {
        for (uint32_t i = 0; i < TYPES; ++i)
        {
@@ -30,9 +30,9 @@ Warn::Warn ()
        }
 }
 
-uint32_t Warn::error_code () const
+bool Warn::error () const
 {
-       return error;
+       return error_accuml;
 }
 
 void Warn::set (type_t t, option_t o)
@@ -68,7 +68,7 @@ void Warn::empty_class (uint32_t line)
        {
                if (mask[EMPTY_CHARACTER_CLASS] & ERROR)
                {
-                       error = true;
+                       error_accuml = true;
                }
                warning (names[EMPTY_CHARACTER_CLASS], "empty character class at line %u", line);
        }
@@ -80,7 +80,7 @@ void Warn::empty_rule (uint32_t line)
        {
                if (mask[EMPTY_RULE] & ERROR)
                {
-                       error = true;
+                       error_accuml = true;
                }
                warning (names[EMPTY_RULE], "empty rule at line %u", line);
        }
@@ -92,7 +92,7 @@ void Warn::naked_default (const std::vector<std::pair<uint32_t, uint32_t> > & st
        {
                if (mask[NAKED_DEFAULT] & ERROR)
                {
-                       error = true;
+                       error_accuml = true;
                }
                std::ostringstream s;
                for (uint32_t i = 0; i < stray_cunits.size (); ++i)
index f0b11fa1bbd9beabfb5b9642e8b2ce5c815e091d..f07304f87f02d6ba0fc1f8495e6f5e47070307cf 100644 (file)
@@ -36,11 +36,11 @@ private:
        static const uint8_t ERROR;
        static const char * names [TYPES];
        uint8_t mask[TYPES];
-       bool error;
+       bool error_accuml;
 
 public:
        Warn ();
-       uint32_t error_code () const;
+       bool error () const;
        void set (type_t t, option_t o);
        void set_all (option_t o);
        void empty_class (uint32_t line);
index fa23b25a6bd213eaf17f3ff707a2892263a70392..ab069d334afa124caa88df56cb2f87118393fe07 100644 (file)
@@ -57,5 +57,5 @@ int main(int argc, char *argv[])
        Scanner scanner (input, output.source);
        parse (scanner, output);
 
-       return warn.error_code ();
+       return warn.error () ? 1 : 0;
 }