Skip to content
Snippets Groups Projects
Commit 27f86668 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Added a simple auto test for our C++ front-end.

parent 56f788cc
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
me=$(dirname $0)
${CPP-gcc} -xc++ -E -include $me/conf.c++ $* | $me/cplusplus0
#define __extension__
#define __context__
#define __range__
#define __asm(a...)
#define __asm__(a...)
#define restrict
#define __restrict
QT = core
macx:CONFIG -= app_bundle
TARGET = cplusplus0
include(../../../shared/cplusplus/cplusplus.pri)
# Input
SOURCES += main.cpp
unix {
debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared
release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared
debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared
release:MOC_DIR = $${OUT_PWD}/.moc/release-shared
RCC_DIR = $${OUT_PWD}/.rcc/
UI_DIR = $${OUT_PWD}/.uic/
}
#include <QFile>
#include <cstdio>
#include <cstdlib>
#include <TranslationUnit.h>
#include <Control.h>
#include <AST.h>
#include <Semantic.h>
#include <Scope.h>
int main(int, char *[])
{
Control control;
StringLiteral *fileId = control.findOrInsertFileName("<stdin>");
QFile in;
if (! in.open(stdin, QFile::ReadOnly))
return EXIT_FAILURE;
const QByteArray source = in.readAll();
TranslationUnit unit(&control, fileId);
unit.setSource(source.constData(), source.size());
unit.parse();
if (TranslationUnitAST *ast = unit.ast()) {
Scope globalScope;
Semantic sem(&control);
for (DeclarationAST *decl = ast->declarations; decl; decl = decl->next) {
sem.check(decl, &globalScope);
}
}
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment