]> git.draconx.ca Git - cdecl99.git/commitdiff
Use assert(0) instead of abort for exceptional cases.
authorNick Bowler <nbowler@draconx.ca>
Mon, 4 Jul 2011 22:11:48 +0000 (18:11 -0400)
committerNick Bowler <nbowler@draconx.ca>
Mon, 4 Jul 2011 22:11:48 +0000 (18:11 -0400)
assert prints helpful context info to stderr.  These cases should never
be reached except by programmer error.

src/explain.c
src/parse-decl.c
src/parse.y

index d8a5f057915191bbf392ef47186a5231e6cf9102..6ab2796acbcc812cbfbccea87cac15480e0e1a20 100644 (file)
@@ -1,6 +1,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <assert.h>
+
 #include "cdecl.h"
 #include "typemap.h"
 
@@ -123,7 +125,7 @@ static const char *explain_storage(unsigned spec)
        case CDECL_STOR_REGISTER:
                return "register";
        default:
-               abort();
+               assert(0);
        }
 }
 
@@ -164,7 +166,7 @@ static struct cdecl_declarator *next_declarator(struct cdecl_declarator *d)
        case CDECL_DECL_ARRAY:
                return d->u.array.declarator;
        default:
-               abort();
+               assert(0);
        }
 }
 
@@ -229,7 +231,7 @@ explain_declarators(char *buf, size_t n, struct cdecl_declarator *d)
        case CDECL_DECL_ARRAY:
                return ret + explain_array(buf, n, &d->u.array);
        default:
-               abort();
+               assert(0);
        }
 }
 
index eb543ec8cc99fc5aafccbc2d1d3c1411430d7cc6..45ade359784acfecaa1d34f19d3b4de870357137 100644 (file)
@@ -42,7 +42,7 @@ static int verify_declspecs(struct cdecl_declspec *s)
                        fprintf(stderr, "only function declarations may have function specifiers.\n");
                        return -1;
                default:
-                       abort();
+                       assert(0);
                }
        }
 
index 8840279b020b9ab8e945eb6ae812254a8297d759..0a2c2b5a1f39c7c494755d2ae50eb8e5f48db039 100644 (file)
@@ -22,6 +22,8 @@
 %locations
 
 %{
+#include <assert.h>
+
 #include "scan.h"
 #include "cdecl.h"
 
@@ -89,7 +91,7 @@ static void free_declarator(struct cdecl_declarator *x)
                        free_declarator(x->u.array.declarator);
                        break;
                default:
-                       abort();
+                       assert(0);
                }
                free(x);
                x = p;