From a80fc936469efc557847796efefa72107dc10d6b Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 5 Nov 2021 12:39:27 -0700 Subject: [PATCH] Fix unused variable treatment (#139) Right now our CMake infra specifies -Wno-unused only for GCC builds, but Makefile specifies it for all builds. The intent has been to use it just for GCC, so we now do that by detecting the compiler version - this should equalize the behavior across different types of builds. Separately, latest version of clang appears to expose an unused variable that clang-10 was okay with, so fix that. (change from upstream) --- Ast/src/Parser.cpp | 5 ----- Makefile | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Ast/src/Parser.cpp b/Ast/src/Parser.cpp index 846bc0ba..ee84542d 100644 --- a/Ast/src/Parser.cpp +++ b/Ast/src/Parser.cpp @@ -2379,15 +2379,12 @@ AstArray Parser::parseTypeParams() Lexeme begin = lexer.current(); nextLexeme(); - bool seenPack = false; while (true) { if (FFlag::LuauParseTypePackTypeParameters) { if (shouldParseTypePackAnnotation(lexer)) { - seenPack = true; - auto typePack = parseTypePackAnnotation(); if (FFlag::LuauTypeAliasPacks) // Type packs are recorded only is we can handle them @@ -2399,8 +2396,6 @@ AstArray Parser::parseTypeParams() if (typePack) { - seenPack = true; - if (FFlag::LuauTypeAliasPacks) // Type packs are recorded only is we can handle them parameters.push_back({{}, typePack}); } diff --git a/Makefile b/Makefile index ea416be4..e96a9cbd 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,10 @@ OBJECTS=$(AST_OBJECTS) $(COMPILER_OBJECTS) $(ANALYSIS_OBJECTS) $(VM_OBJECTS) $(T CXXFLAGS=-g -Wall -Werror LDFLAGS= -CXXFLAGS+=-Wno-unused # temporary, for older gcc versions +# temporary, for older gcc versions as they treat var in `if (type var = val)` as unused +ifeq ($(findstring g++,$(shell $(CXX) --version)),g++) + CXXFLAGS+=-Wno-unused +endif # configuration-specific flags ifeq ($(config),release)