) type.castTo(rExpression)));
break;
default:
- throw new RuntimeException("Bad operator: " + operator);
+ throw new UnsupportedFrontendElementException("Unsupported operator: " + operator);
}
parseContext.getMetadata().create(ret, "cType", CComplexType.getType(lValue, parseContext));
ret = CComplexType.getType(lValue, parseContext).castTo(ret);
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java
index 4d7670b096..d12151fe4b 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java
@@ -19,6 +19,7 @@
import hu.bme.mit.theta.common.Tuple2;
import hu.bme.mit.theta.core.type.Expr;
import hu.bme.mit.theta.frontend.ParseContext;
+import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType;
import java.util.ArrayList;
@@ -38,7 +39,7 @@ public CInitializerList(CComplexType type, ParseContext parseContext) {
@Override
public Expr> getExpression() {
- throw new UnsupportedOperationException("Cannot create expression of initializer list.");
+ throw new UnsupportedFrontendElementException("Cannot create expression of initializer list.");
}
@Override
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java
index 44f8087a79..93a2199239 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java
@@ -18,6 +18,7 @@
import hu.bme.mit.theta.core.type.Expr;
import hu.bme.mit.theta.frontend.ParseContext;
+import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException;
/**
* Every Program, Function and Statement is a subclass of this base class.
@@ -60,7 +61,7 @@ public void setId(String id) {
* @return The expression associated with the statement.
*/
public Expr> getExpression() {
- throw new RuntimeException("Cannot get expression!");
+ throw new UnsupportedFrontendElementException("Cannot get expression!");
}
public CStatement getPostStatements() {
@@ -68,7 +69,7 @@ public CStatement getPostStatements() {
}
public void setPostStatements(CStatement postStatements) {
- throw new UnsupportedOperationException("Only CCompounds shall currently have pre- and post statements!");
+ throw new UnsupportedFrontendElementException("Only CCompounds shall currently have pre- and post statements!");
}
public CStatement getPreStatements() {
@@ -76,7 +77,7 @@ public CStatement getPreStatements() {
}
public void setPreStatements(CStatement preStatements) {
- throw new UnsupportedOperationException("Only CCompounds shall currently have pre- and post statements!");
+ throw new UnsupportedFrontendElementException("Only CCompounds shall currently have pre- and post statements!");
}
public abstract R accept(CStatementVisitor
visitor, P param);
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java
index 32b8c4b0e4..1f54441d28 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java
@@ -26,11 +26,8 @@
import hu.bme.mit.theta.core.type.fptype.FpType;
import hu.bme.mit.theta.core.type.inttype.IntType;
import hu.bme.mit.theta.frontend.ParseContext;
-import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CArray;
-import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CCompound;
-import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CFunction;
-import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer;
-import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CStruct;
+import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException;
+import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.*;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.integer.CInteger;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.integer.Fitsall;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.integer.c128.C128;
@@ -62,12 +59,7 @@
import java.util.Map.Entry;
import java.util.Optional;
-import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getCastVisitor;
-import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getLimitVisitor;
-import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getNullValueVisitor;
-import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getTypeVisitor;
-import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getUnitValueVisitor;
-import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getValueVisitor;
+import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.*;
public abstract class CComplexType {
private final CSimpleType origin;
@@ -208,7 +200,7 @@ private static CComplexType getType(Type type, ParseContext parseContext) {
if (longDoubleType.equals(type)) {
return new CFloat(null, parseContext);
}
- throw new RuntimeException("No suitable size found for type: " + type);
+ throw new UnsupportedFrontendElementException("No suitable size found for type: " + type);
} else if (type instanceof BvType) {
for (Entry entry : parseContext.getArchitecture().standardTypeSizes.entrySet()) {
String s = entry.getKey();
@@ -230,9 +222,9 @@ private static CComplexType getType(Type type, ParseContext parseContext) {
}
}
}
- throw new RuntimeException("No suitable width found for type: " + type);
+ throw new UnsupportedFrontendElementException("No suitable width found for type: " + type);
} else {
- throw new RuntimeException("Not yet implemented for type: " + type);
+ throw new UnsupportedFrontendElementException("Not yet implemented for type: " + type);
}
}
@@ -307,7 +299,7 @@ public R accept(CComplexTypeVisitor visitor, T param) {
public static class CComplexTypeVisitor {
public R visit(CComplexType type, T param) {
- throw new UnsupportedOperationException("Not (yet) implemented (" + type.getClass().getSimpleName() + " in " + this.getClass().getName() + ")");
+ throw new UnsupportedFrontendElementException("Not (yet) implemented (" + type.getClass().getSimpleName() + " in " + this.getClass().getName() + ")");
}
public R visit(CVoid type, T param) {
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CVoid.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CVoid.java
index 4d9d121d1e..353ca2cc9a 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CVoid.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CVoid.java
@@ -29,6 +29,11 @@ public R accept(CComplexTypeVisitor visitor, T param) {
return visitor.visit(this, param);
}
+ @Override
+ public CComplexType getSmallestCommonType(CComplexType type) {
+ return type;
+ }
+
@Override
public String getTypeName() {
return "void";
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java
index 6550e48040..8cb56130a7 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java
@@ -41,7 +41,7 @@ public String getTypeName() {
@Override
public CInteger getSignedVersion() {
- throw new RuntimeException("Bool does not have a signed version!");
+ throw new RuntimeException("Fitsall does not have a signed version!");
}
@Override
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java
index ab2fd3faa7..6187ff3391 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java
@@ -25,6 +25,7 @@
import hu.bme.mit.theta.core.type.fptype.FpRoundingMode;
import hu.bme.mit.theta.core.type.fptype.FpType;
import hu.bme.mit.theta.frontend.ParseContext;
+import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.CVoid;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer;
@@ -89,7 +90,7 @@ private Expr extends Type> handleSignedConversion(CInteger type, Expr> param
}
}
} else {
- throw new IllegalStateException("Compound types are not directly supported!");
+ throw new UnsupportedFrontendElementException("Compound types are not directly supported!");
}
}
@@ -119,7 +120,7 @@ private Expr extends Type> handleUnsignedConversion(CInteger type, Expr> par
}
}
} else {
- throw new IllegalStateException("Compound types are not directly supported!");
+ throw new UnsupportedFrontendElementException("Compound types are not directly supported!");
}
}
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java
index 2cbc83220d..2ff2c5fdb0 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java
@@ -19,6 +19,7 @@
import hu.bme.mit.theta.common.logging.Logger;
import hu.bme.mit.theta.common.logging.Logger.Level;
import hu.bme.mit.theta.frontend.ParseContext;
+import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.CVoid;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer;
@@ -169,7 +170,7 @@ protected void patch(CSimpleType cSimpleType) {
break;
default:
if (!cSimpleType.isTypedef()) {
- throw new RuntimeException(
+ throw new UnsupportedFrontendElementException(
"namedType should be short or long or type specifier, instead it is "
+ namedType);
}
diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/Struct.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/Struct.java
index eb3d8ad12f..a7b55db04d 100644
--- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/Struct.java
+++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/Struct.java
@@ -20,7 +20,9 @@
import hu.bme.mit.theta.common.logging.Logger;
import hu.bme.mit.theta.common.logging.Logger.Level;
import hu.bme.mit.theta.frontend.ParseContext;
+import hu.bme.mit.theta.frontend.transformation.model.declaration.CDeclaration;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType;
+import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer;
import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CStruct;
import java.util.ArrayList;
@@ -28,9 +30,11 @@
import java.util.List;
import java.util.Map;
+import static com.google.common.base.Preconditions.checkNotNull;
+
public class Struct extends NamedType {
- private final Map fields;
+ private final Map fields;
private final String name;
private final Logger uniqueWarningLogger;
@@ -52,8 +56,8 @@ public static Struct getByName(String name) {
currentlyBeingBuilt = false;
}
- public void addField(String name, CSimpleType type) {
- fields.put(name, type);
+ public void addField(CDeclaration decl) {
+ fields.put(checkNotNull(decl.getName()), checkNotNull(decl));
}
@Override
@@ -64,9 +68,16 @@ public CComplexType getActualType() {
}
currentlyBeingBuilt = true;
List> actualFields = new ArrayList<>();
- fields.forEach((s, cSimpleType) -> actualFields.add(Tuple2.of(s, cSimpleType.getActualType())));
+ fields.forEach((s, cDeclaration) -> actualFields.add(Tuple2.of(s, cDeclaration.getActualType())));
currentlyBeingBuilt = false;
- return new CStruct(this, actualFields, parseContext);
+
+ CComplexType type = new CStruct(this, actualFields, parseContext);
+
+ for (int i = 0; i < getPointerLevel(); i++) {
+ type = new CPointer(this, type, parseContext);
+ }
+
+ return type;
}
@Override
diff --git a/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt b/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt
index 6dccaaa36c..d82a92fa4a 100644
--- a/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt
+++ b/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt
@@ -94,7 +94,9 @@ class FrontendXcfaBuilder(val parseContext: ParseContext, val checkOverflow: Boo
continue
}
if (type is CStruct) {
- error("Not handling init expression of struct array ${globalDeclaration.get1()}")
+ uniqueWarningLogger.write(
+ Logger.Level.INFO, "Not handling init expression of struct array ${globalDeclaration.get1()}"
+ )
}
builder.addVar(XcfaGlobalVar(globalDeclaration.get2(), type.nullValue))
if (type is CArray) {
@@ -190,7 +192,7 @@ class FrontendXcfaBuilder(val parseContext: ParseContext, val checkOverflow: Boo
for (flatVariable in flatVariables) {
builder.addVar(flatVariable)
val type = CComplexType.getType(flatVariable.ref, parseContext)
- if (type is CArray && builder.getParams().none { it.first == flatVariable }) {
+ if ((type is CArray || type is CStruct) && builder.getParams().none { it.first == flatVariable }) {
initStmtList.add(StmtLabel(
Stmts.Assign(cast(flatVariable, flatVariable.type),
cast(type.getValue("$ptrCnt"), flatVariable.type))
diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/XcfaCli.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/XcfaCli.kt
index f5257effa4..54e2c0d406 100644
--- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/XcfaCli.kt
+++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/XcfaCli.kt
@@ -41,6 +41,9 @@ class XcfaCli(private val args: Array) {
@Parameter(names = ["--help", "-h"], help = true)
private var help = false
+ @Parameter(names = ["--svcomp"])
+ private var svcomp = false
+
@Parameter
var remainingFlags: MutableList = ArrayList()
@@ -55,6 +58,18 @@ class XcfaCli(private val args: Array) {
} else {
config = XcfaConfig()
}
+ if (svcomp) {
+ remainingFlags.addAll(
+ listOf(
+ "--enable-output",
+ "--disable-xcfa-serialization",
+ "--disable-arg-generation",
+ "--disable-chc-serialization",
+ "--disable-c-serialization",
+ "--only-svcomp-witness"
+ )
+ )
+ }
while (remainingFlags.isNotEmpty()) {
val nextArgs = remainingFlags.toTypedArray()
remainingFlags.clear()
diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt
index 563a7abaa3..1ecf5e665a 100644
--- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt
+++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt
@@ -18,6 +18,7 @@ package hu.bme.mit.theta.xcfa.cli.params
import com.microsoft.z3.Z3Exception
import hu.bme.mit.theta.common.exception.NotSolvableException
+import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException
import hu.bme.mit.theta.solver.UnknownSolverStatusException
import hu.bme.mit.theta.solver.javasmt.JavaSMTSolverException
import hu.bme.mit.theta.solver.smtlib.solver.SmtLibSolverException
@@ -32,6 +33,7 @@ enum class ExitCodes(val code: Int) {
SERVER_ERROR(202),
PORTFOLIO_ERROR(203),
+ UNSUPPORTED_ELEMENT(209),
FRONTEND_FAILED(210),
INVALID_PARAM(211),
@@ -59,6 +61,9 @@ fun exitOnError(stacktrace: Boolean, throwDontExit: Boolean, body: () -> T):
} catch (e: ErrorCodeException) {
e.printStackTrace()
exitProcess(throwDontExit, e, e.code)
+ } catch (e: UnsupportedFrontendElementException) {
+ e.printCauseAndTrace(stacktrace)
+ exitProcess(throwDontExit, e, ExitCodes.UNSUPPORTED_ELEMENT.code)
} catch (e: SmtLibSolverException) {
e.printCauseAndTrace(stacktrace)
exitProcess(throwDontExit, e, ExitCodes.SOLVER_ERROR.code)