carbon-lang
carbon-lang copied to clipboard
llvm-15: Issue with bison parser.ypp and clang -Wall -Werror
I'm on debian 11 (bullseye), which only comes with llvm-11, but installed llvm-15 (and related) through https://apt.llvm.org/
I've almost got explorer working, until I've hit this one:
bazel-out/k8-opt/bin/explorer/syntax/parser.cpp:1050:9: error: variable 'yynerrs_' set but not used [-Werror,-Wunused-but-set-variable]
then googled and found possible solution (possible, because I don't know if it's right)
malkia@penguin:~/p/carbon-language/carbon-lang$ git diff
diff --git a/explorer/syntax/parser.ypp b/explorer/syntax/parser.ypp
index 79e9357..df3fdae 100644
--- a/explorer/syntax/parser.ypp
+++ b/explorer/syntax/parser.ypp
@@ -91,6 +91,13 @@
}
} // %code
+%code {
+#if defined(__clang__)
+// Clang warns that the variable 'yynerrs_' is set but not used.
+#pragma clang diagnostic ignored "-Wunused-but-set-variable"
+#endif
+}
+
%token <int> integer_literal
%token <std::string> identifier
%token <IntrinsicExpression::Intrinsic> intrinsic_identifier
It now compiles :) - but haven't it run it yet! Thanks for this exciting new language!
Do you still have this problem if you use a homebrew installation of llvm instead of the apt-provided one?
I suspect this is due to the use of llvm-15; annotated. llvm-15 isn't stable yet, but this may just be newer error detection changes, so it's still worth fixing this for when it's eventually fixed.