Added a test case for #define/#undef/#ifdef/#ifndef/#else/#endif
This commit is contained in:
parent
1f0ec35d48
commit
bd0fc7289a
1
Makefile
1
Makefile
|
@ -46,6 +46,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/common.h \
|
$(PACKAGE)-$(VERSION)/src/common.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/parser.h \
|
$(PACKAGE)-$(VERSION)/src/parser.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/project.conf \
|
$(PACKAGE)-$(VERSION)/src/project.conf \
|
||||||
|
$(PACKAGE)-$(VERSION)/tests/define.cpp \
|
||||||
$(PACKAGE)-$(VERSION)/tests/if.cpp \
|
$(PACKAGE)-$(VERSION)/tests/if.cpp \
|
||||||
$(PACKAGE)-$(VERSION)/tests/Makefile \
|
$(PACKAGE)-$(VERSION)/tests/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/tests/cpp.sh \
|
$(PACKAGE)-$(VERSION)/tests/cpp.sh \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
TARGETS = if.o
|
TARGETS = define.o if.o
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
@ -13,14 +13,20 @@ INSTALL = install
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
define.o_OBJS = define.o
|
||||||
|
define.o_CXXFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
if.o_OBJS = if.o
|
if.o_OBJS = if.o
|
||||||
if.o_CXXFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CXXFLAGS)
|
if.o_CXXFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
|
define.o: define.cpp cpp.sh
|
||||||
|
$(CXX) $(define.o_CXXFLAGS) -c define.cpp
|
||||||
|
|
||||||
if.o: if.cpp cpp.sh
|
if.o: if.cpp cpp.sh
|
||||||
$(CXX) $(if.o_CXXFLAGS) -c if.cpp
|
$(CXX) $(if.o_CXXFLAGS) -c if.cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(if.o_OBJS)
|
$(RM) -- $(define.o_OBJS) $(if.o_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
|
25
tests/define.cpp
Normal file
25
tests/define.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#ifdef GOOD
|
||||||
|
#error error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GOOD 1
|
||||||
|
|
||||||
|
#ifdef GOOD
|
||||||
|
#warning good
|
||||||
|
#else
|
||||||
|
#error error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GOOD
|
||||||
|
#error error
|
||||||
|
#else
|
||||||
|
#warning good
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef GOOD
|
||||||
|
|
||||||
|
#ifndef GOOD
|
||||||
|
#warning good
|
||||||
|
#else
|
||||||
|
#error error
|
||||||
|
#endif
|
1
tests/define.o
Normal file
1
tests/define.o
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#define GOOD 1 2
|
31
tests/if.o
Normal file
31
tests/if.o
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#if 0
|
||||||
|
#warning good
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
#warning good
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define GOOD 1
|
||||||
|
#if GOOD
|
||||||
|
#warning good
|
||||||
|
#else
|
||||||
|
#undef GOOD
|
||||||
|
|
||||||
|
#define GOOD 0
|
||||||
|
#if !GOOD
|
||||||
|
#warning good
|
||||||
|
#else
|
||||||
|
#undef GOOD
|
||||||
|
|
||||||
|
#define GOOD 1
|
||||||
|
#if 0
|
||||||
|
#warning good
|
||||||
|
#endif
|
||||||
|
#undef GOOD
|
||||||
|
|
||||||
|
#define GOOD 0
|
||||||
|
#if 0
|
||||||
|
#warning good
|
||||||
|
#endif
|
||||||
|
#undef GOOD
|
|
@ -1,8 +1,15 @@
|
||||||
targets=if.o
|
targets=define.o,if.o
|
||||||
cxx=./cpp.sh
|
cxx=./cpp.sh
|
||||||
cxxflags=
|
cxxflags=
|
||||||
dist=Makefile,cpp.sh
|
dist=Makefile,cpp.sh
|
||||||
|
|
||||||
|
[define.o]
|
||||||
|
type=object
|
||||||
|
sources=define.cpp
|
||||||
|
|
||||||
|
[define.cpp]
|
||||||
|
depends=cpp.sh
|
||||||
|
|
||||||
[if.o]
|
[if.o]
|
||||||
type=object
|
type=object
|
||||||
sources=if.cpp
|
sources=if.cpp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user