When operator new is used on a class with no constructor it generates an AGGR_INIT_EXPR, not a CALL_EXPR... with testcase. NPODB, static-checking only.

This commit is contained in:
Benjamin Smedberg
2008-12-03 11:49:54 -05:00
parent 5be7b713bf
commit e93d279a87
3 changed files with 19 additions and 3 deletions

View File

@@ -167,11 +167,12 @@ function process_cp_pre_genericize(fndecl)
break; break;
case CALL_EXPR: case CALL_EXPR:
case AGGR_INIT_EXPR:
assign = stack[i + 1]; assign = stack[i + 1];
break; break;
default: default:
error("Unrecognized assignment from operator new: " + TREE_CODE(assign), getLocation()); error("Unrecognized assignment from operator new: %s. Tree code stack: %s".format(TREE_CODE(assign), [TREE_CODE(s) for each (s in stack)].join(",")), getLocation());
return; return;
} }

View File

@@ -57,6 +57,7 @@ STACK_FAILURE_TESTCASES = \
StackNoConstructor.cpp \ StackNoConstructor.cpp \
StackVector.cpp \ StackVector.cpp \
StackConditional.cpp \ StackConditional.cpp \
StackAggrInit.cpp \
$(NULL) $(NULL)
STACK_PASS_TESTCASES = \ STACK_PASS_TESTCASES = \
@@ -121,6 +122,8 @@ STATIC_PASS_TESTCASES = \
$(FLOW_PASS_TESTCASES) \ $(FLOW_PASS_TESTCASES) \
$(NULL) $(NULL)
REQUIRES = xpcom
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
# We want to compile each file and invert the result to ensure that # We want to compile each file and invert the result to ensure that
@@ -142,13 +145,13 @@ check:: \
%.s-warn: %.cpp $(GLOBAL_DEPS) $(DEHYDRA_SCRIPTS) %.s-warn: %.cpp $(GLOBAL_DEPS) $(DEHYDRA_SCRIPTS)
@printf "Compiling $(<F) to check that the static-analysis script is checking properly..." @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) -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" \ printf "fail:\nerror: compilation of $(<F) succeeded with -Werror. It shouldn't have!\n"; \
exit 1; \ exit 1; \
fi fi
@if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).werrlog 2>&1; then \ @if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).werrlog 2>&1; then \
printf "ok.\n"; \ printf "ok.\n"; \
else \ else \
printf "fail:\nerror: compilation of $(<F) without -Werror failed. A warning should have been issued.\n" \ printf "fail:\nerror: compilation of $(<F) without -Werror failed. A warning should have been issued.\n"; \
exit 1; \ exit 1; \
fi fi

View File

@@ -0,0 +1,12 @@
#include "nscore.h"
#include "nsAutoPtr.h"
class NS_STACK_CLASS A
{
int i;
};
void Foo()
{
nsAutoPtr<A> a(new A);
}