Bug 432278 - Fix a couple of the static-checking testcases: clean up the makefile-fu a little bit, and add a new class of test: one which should issue warnings, which equates to "should fail with -Werror and should pass without -Werror." r=dmandelin

This commit is contained in:
Benjamin Smedberg 2008-05-05 14:32:31 -04:00
parent 4393fe5a30
commit 9aaf941d31
3 changed files with 40 additions and 7 deletions

View File

@ -47,14 +47,17 @@ GARBAGE_DIRS += $(MDDEPDIR)
include $(DEPTH)/config/autoconf.mk
STATIC_FAILURE_TESTCASES = \
FINAL_FAILURE_TESTCASES = \
TestFinal.cpp \
TestFinalTemplate.cpp \
$(NULL)
STACK_FAILURE_TESTCASES = \
TestStack.cpp \
TestStackTemplate.cpp \
$(NULL)
OUTPARAMS_FAILURE_TESTCASES = \
OUTPARAMS_WARNING_TESTCASES = \
e1.cpp \
e2.cpp \
e3.cpp \
@ -82,25 +85,53 @@ OUTPARAMS_PASS_TESTCASES = \
o11.cpp \
$(NULL)
STATIC_FAILURE_TESTCASES = \
$(FINAL_FAILURE_TESTCASES) \
$(STACK_FAILURE_TESTCASES) \
$(NULL)
STATIC_WARNING_TESTCASES = \
$(OUTPARAMS_WARNING_TESTCASES) \
$(NULL)
STATIC_PASS_TESTCASES = \
$(OUTPARAMS_PASS_TESTCASES) \
$(NULL)
include $(topsrcdir)/config/rules.mk
# We want to compile each file and invert the result to ensure that
# compilation failed.
check:: $(STATIC_FAILURE_TESTCASES:.cpp=.s-fail) \
$(OUTPARAMS_FAILURE_TESTCASES:.cpp=.s-fail) $(OUTPARAMS_PASS_TESTCASES:.cpp=.s-pass)
check:: \
$(STATIC_FAILURE_TESTCASES:.cpp=.s-fail) \
$(STATIC_WARNING_TESTCASES:.cpp=.s-warn) \
$(STATIC_PASS_TESTCASES:.cpp=.s-pass)
%.s-fail: %.cpp Makefile Makefile.in $(DEHYDRA_SCRIPTS)
@printf "Compiling $(<F) to check that the static-analysis script is checking properly..."
@if $(CCC) -Werror $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
@if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
printf "fail:\nerror: compilation of $(<F) succeeded. It shouldn't have!\n"; \
exit 1; \
else \
printf "ok.\n"; \
fi
%.s-warn: %.cpp Makefile Makefile.in $(DEHYDRA_SCRIPTS)
@printf "Compiling $(<F) to check that the static-analysis script is checking properly..."
@if $(CCC) -Werror $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
printf "fail:\nerror: compilation of $(<F) succeeded with -Werror. It shouldn't have!\n" \
exit 1; \
fi
@if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).werrlog 2>&1; then \
printf "ok.\n"; \
else \
printf "fail:\nerror: compilation of $(<F) without -Werror failed. A warning should have been issued.\n" \
exit 1; \
fi
%.s-pass: %.cpp Makefile Makefile.in $(DEHYDRA_SCRIPTS)
@printf "Compiling $(<F) to check that the static-analysis script is checking properly..."
@if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
@if $(CCC) -Werror $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
printf "ok.\n"; \
else \
printf "fail:\nerror: compilation of $(<F) failed. It shouldn't have!\n"; \

View File

@ -4,6 +4,8 @@ typedef int PRInt32;
typedef PRUint32 nsresult;
typedef short PRUnichar;
class nsACString;
nsresult bar(nsACString &a);
nsresult baz();

View File

@ -3,6 +3,6 @@ typedef int PRInt32;
typedef PRUint32 nsresult;
nsresult foo(__attribute__((user("inoutparam"))) int *a) {
nsresult foo(__attribute__((user("NS_inoutparam"))) int *a) {
return 0;
}