summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Graef2022-08-07 23:51:32 +0200
committerAlbert Graef2022-08-07 23:51:32 +0200
commit6f851b27e3f5a351e69a3fe392de06a2d6c142cd (patch)
tree78847c3f750fff5e4f17bec4b4a89c90ada17bbf
parent7e88ba269da911a002860fb55a9058e5511f4c17 (diff)
downloadaur-6f851b27e3f5a351e69a3fe392de06a2d6c142cd.tar.gz
Improved diagnostics for unrecognized enum values.
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD14
-rw-r--r--enums.patch44
3 files changed, 58 insertions, 4 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 20f2f90a455b..adf015f5403c 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = pure-gen
pkgdesc = A C interface generator for Pure
pkgver = 0.25
- pkgrel = 1
+ pkgrel = 2
url = https://agraef.github.io/pure-lang/
arch = i686
arch = x86_64
@@ -17,6 +17,8 @@ pkgbase = pure-gen
depends = pure
depends = numactl
source = https://github.com/agraef/pure-lang/releases/download/pure-gen-0.25/pure-gen-0.25.tar.gz
+ source = enums.patch
sha1sums = c77a63a5f6456aee4a5ad0676fdd2f8925c16412
+ sha1sums = 982d929a1a0d4e40fc3754c1290c344c950e0148
pkgname = pure-gen
diff --git a/PKGBUILD b/PKGBUILD
index 63e000f3ccad..ecd03b8b51a2 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@
pkgname=pure-gen
pkgver=0.25
-pkgrel=1
+pkgrel=2
pkgdesc="A C interface generator for Pure"
arch=("i686" "x86_64")
license=('custom')
@@ -11,8 +11,16 @@ url="https://agraef.github.io/pure-lang/"
depends=('pure' 'numactl')
makedepends=('ghc' 'ghc-static' 'ghc-pristine' 'cabal-install' 'alex' 'happy')
groups=(pure-complete pure-util)
-source=("https://github.com/agraef/pure-lang/releases/download/$pkgname-$pkgver/$pkgname-$pkgver.tar.gz")
-sha1sums=('c77a63a5f6456aee4a5ad0676fdd2f8925c16412')
+source=("https://github.com/agraef/pure-lang/releases/download/$pkgname-$pkgver/$pkgname-$pkgver.tar.gz"
+ "enums.patch")
+sha1sums=('c77a63a5f6456aee4a5ad0676fdd2f8925c16412'
+ '982d929a1a0d4e40fc3754c1290c344c950e0148')
+
+prepare() {
+ cd $srcdir/$pkgname-$pkgver
+ # improved handling of unrecognized enums in C/C++ source
+ patch -p2 -i ../enums.patch
+}
build() {
cd $srcdir/$pkgname-$pkgver
diff --git a/enums.patch b/enums.patch
new file mode 100644
index 000000000000..6d67510e0f5f
--- /dev/null
+++ b/enums.patch
@@ -0,0 +1,44 @@
+commit 94259306f5407dd28d9417f87c118ed1f6326601
+Author: Albert Graef <aggraef@gmail.com>
+Date: Sun Aug 7 23:29:46 2022 +0200
+
+ pure-gen: Improve diagnostics for unrecognized enum values.
+
+diff --git a/pure-gen/pure-gen.pure b/pure-gen/pure-gen.pure
+index 694aeeab..15b38f4d 100755
+--- a/pure-gen/pure-gen.pure
++++ b/pure-gen/pure-gen.pure
+@@ -588,10 +588,21 @@ get_enum dict _ = dict;
+
+
+ calc_enum_values dict prev ((name,Just e):more) =
+- case eval_expr dict e of
++case catch id (eval_expr dict e) of
+ val::int = calc_enum_values (insert dict (name => val)) val more;
+- x = warning 0 $ "Couldn't evaluate enum expression for "+name+" : "+str e
+- $$ calc_enum_values dict prev more;
++ x = warning level $ "Unknown enum value: "+name+" = "+str e
++ $$ calc_enum_values dict prev more when
++ estr = str e;
++ // Most of the time e will be 'Pass' which indicates a part of the
++ // AST we (or rather dump-ast) doesn't recognize. These values are
++ // considered unsupported by design, so a simple warning should
++ // suffice, which the user can get rid of with the -w0 option.
++ // OTOH, if we get anything else then it is a part of the AST that
++ // we probably *should* recognize, indicating a possible bug in
++ // pure-gen or dump-ast, or both. In that case we want to ensure
++ // that a warning is printed no matter what.
++ level = estr == "Pass";
++ end;
+ end;
+
+ calc_enum_values dict () ((name,Nothing):more) =
+@@ -639,7 +650,7 @@ eval_expr d (CBinary CXorOp e1 e2) = xor (eval_expr d e1) (eval_expr d e2)
+ with
+ xor a b = (a and not b) or (not a and b); // why exclude poor xor?
+ end;
+-eval_expr d x = warning 0$"Unknown expression type "+str x+" in enum definition. Defaulting to 0." $$ 0;
++eval_expr d x = throw "Unknown expression type";
+
+
+ // Dissect cpp lines (#define's and # lineno only).