Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts p2900 contract violation #8

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 306 additions & 44 deletions gcc/cp/contracts.cc

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions gcc/cp/contracts.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum contract_semantic
CCS_MAYBE
};


/* True if the contract is unchecked. */

inline bool
Expand Down Expand Up @@ -75,6 +76,28 @@ struct contract_role
contract_semantic axiom_semantic;
};

/* P2900 contract clasification */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a comment here that these need to be kept in sync with libstdc++/src/std{/experimental}/contracts.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/* Must match relevant enums in <contracts> header */

enum constract_assertion_kind {
CAK_INVALID = 0 ,
CAK_PRE = 1 ,
CAK_POST = 2 ,
CAK_ASSERT = 3
};

enum constract_evaluation_semantic {
CES_INVALID = 0,
CES_ENFORCE = 1 ,
CES_OBSERVE = 2
};

enum constract_detection_mode {
CDM_PREDICATE_FALSE = 1 ,
CDM_EVAL_EXCEPTION = 2
};


/* Information for configured contract semantics. */

struct contract_configuration
Expand Down
10 changes: 5 additions & 5 deletions gcc/testsuite/g++.dg/contracts/cpp26/contract-assert-run.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// { dg-do run }
// { dg-options "-std=c++2a -fcontracts -fcontracts-nonattr -fcontract-continuation-mode=on" }
#include <iostream>
#include <experimental/contract>
#include "../../../../../libstdc++-v3/include/std/contracts"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that does not look right;
we need to arrange to install the header in either the eventual position - or (with conditionalised content) keep it in <experimental/contracts>. We can add a __cpp_xxxxx to control what the include does - is there one defined for P2900? .. it looks like there might be several from the code below?


#define VERIFY_ASSERT(statement, asserts) \
{ \
Expand All @@ -27,12 +27,12 @@ static_assert (__cpp_contracts >= 201906);
static_assert (__cpp_contracts_literal_semantics >= 201906);
static_assert (__cpp_contracts_roles >= 201906);

void handle_contract_violation(const std::experimental::contract_violation &violation) {
void handle_contract_violation(const std::contracts::contract_violation &violation) {
std::cerr << "custom std::handle_contract_violation called:"
<< " " << violation.line_number()
<< " " << violation.file_name()
<< " " << violation.location().line()
<< " " << violation.location().file_name()
<< std::endl;
throw -(int)violation.line_number();
throw -(int)violation.location().line();
}

void foo(int x) pre (x>10){};
Expand Down
23 changes: 23 additions & 0 deletions gcc/testsuite/g++.dg/contracts/cpp26/contract_violation.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// test that contracts on overriding functions are found correctly
// { dg-do run }
// { dg-options "-std=c++2a -fcontracts -fcontract-continuation-mode=on -fcontracts-nonattr " }

int foo(const int i) pre( i > 3) post (r: r > 4){

contract_assert( i > 5);
return i;
};

int main(int, char**)
{

foo (1);
}
// { dg-output "contract violation in function foo at .*5: i > 3.*(\n|\r\n|\r)" }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }

// { dg-output "contract violation in function foo at .*7: i > 5.*(\n|\r\n|\r)" }
// { dg-output ".assertion_kind: assert, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }

// { dg-output "contract violation in function foo at .*5: r > 4.*(\n|\r\n|\r)" }
// { dg-output ".assertion_kind: post, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
108 changes: 54 additions & 54 deletions gcc/testsuite/g++.dg/contracts/cpp26/contracts-tmpl-spec2.C
Original file line number Diff line number Diff line change
Expand Up @@ -305,143 +305,143 @@ int main(int, char**)
}

// { dg-output {contract violation in function body<int> at .*:9: a > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {-2(\n|\r\n|\r)} }
// { dg-output {contract violation in function body<double> at .*:17: a > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {-3(\n|\r\n|\r)} }
// { dg-output {contract violation in function none<int> at .*:25: a > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {1(\n|\r\n|\r)} }
// { dg-output {contract violation in function none<double> at .*:32: a > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {-101(\n|\r\n|\r)} }
// { dg-output {contract violation in function arg0<int> at .*:39: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {-9(\n|\r\n|\r)} }
// { dg-output {contract violation in function arg0<double> at .*:46: t > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {11(\n|\r\n|\r)} }
// { dg-output {contract violation in function arg1<int> at .*:53: a > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function arg1<int> at .*:54: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {-3(\n|\r\n|\r)} }
// { dg-output {contract violation in function arg1<double> at .*:61: a > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function arg1<double> at .*:62: t > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {14(\n|\r\n|\r)} }
// { dg-output {contract violation in function ret<int> at .*:69: a > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {1(\n|\r\n|\r)} }
// { dg-output {contract violation in function ret<double> at .*:76: a > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {3(\n|\r\n|\r)} }
// { dg-output {contract violation in function ret<double> at .*:76: a > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {3.300000(\n|\r\n|\r)} }
// { dg-output {contract violation in function g1<int> at .*:83: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {-1(\n|\r\n|\r)} }
// { dg-output {-1(\n|\r\n|\r)} }
// { dg-output {contract violation in function g2<int> at .*:97: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {-1(\n|\r\n|\r)} }
// { dg-output {contract violation in function g2<double> at .*:107: t < 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {1(\n|\r\n|\r)} }
// { dg-output {contract violation in function g2<char> at .*:114: t < 'c'(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {100(\n|\r\n|\r)} }
// { dg-output {contract violation in function G3<double, double>::f at .*:124: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G3<double, double>::f at .*:125: s > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G3 general T S(\n|\r\n|\r)} }
// { dg-output {contract violation in function G3<int, int>::f at .*:139: t > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G3<int, int>::f at .*:140: s > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G3 partial int S(\n|\r\n|\r)} }
// { dg-output {contract violation in function G3<int, double>::f at .*:147: t > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G3<int, double>::f at .*:148: s > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G3 full int double(\n|\r\n|\r)} }
// { dg-output {contract violation in function G3<char, char>::f at .*:124: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G3<char, char>::f at .*:125: s > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G3 general T S(\n|\r\n|\r)} }
// { dg-output {contract violation in function G3<int, char>::f at .*:139: t > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G3<int, char>::f at .*:140: s > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G3 partial int S(\n|\r\n|\r)} }
// { dg-output {G3 full int C(\n|\r\n|\r)} }
// { dg-output {G3 full int C(\n|\r\n|\r)} }
// { dg-output {contract violation in function G4<int, int>::G4 at .*:173: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G4<int, int>::G4 at .*:174: s > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G4 general T S(\n|\r\n|\r)} }
// { dg-output {contract violation in function G4<int, int>::G4 at .*:175: x > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: post, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G4 full double double(\n|\r\n|\r)} }
// { dg-output {contract violation in function G4<double, char>::G4 at .*:206: a > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G4<double, char>::G4 at .*:207: b > 'b'(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G4 full double char(\n|\r\n|\r)} }
// { dg-output {contract violation in function G4<double, char>::G4 at .*:208: x > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: post, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G4<char, int>::G4 at .*:187: t > 'c'(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G4<char, int>::G4 at .*:188: s > 3(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G4 partial char S(\n|\r\n|\r)} }
// { dg-output {contract violation in function G4<char, int>::G4 at .*:189: x2 > 3(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: post, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<int, int>::f<int> at .*:220: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<int, int>::f<int> at .*:221: s > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<int, int>::f<int> at .*:222: r > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G5 gen T S, f gen R(\n|\r\n|\r)} }
// { dg-output {contract violation in function G5<int, int>::f<double> at .*:220: t > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<int, int>::f<double> at .*:221: s > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<int, int>::f<double> at .*:222: r > 0(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G5 gen T S, f gen R(\n|\r\n|\r)} }
// { dg-output {contract violation in function G5<char, int>::f<int> at .*:233: x > 'z'(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<char, int>::f<int> at .*:234: y > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<char, int>::f<int> at .*:235: z > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G5 partial char S, f gen R(\n|\r\n|\r)} }
// { dg-output {contract violation in function G5<char, int>::f<double> at .*:233: x > 'z'(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<char, int>::f<double> at .*:234: y > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<char, int>::f<double> at .*:235: z > 1(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G5 partial char S, f gen R(\n|\r\n|\r)} }
// { dg-output {contract violation in function G5<double, double>::f<int> at .*:244: a > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<double, double>::f<int> at .*:245: b > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<double, double>::f<int> at .*:246: c > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G5 full double double, f gen R(\n|\r\n|\r)} }
// { dg-output {contract violation in function G5<double, double>::f<double> at .*:244: a > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<double, double>::f<double> at .*:245: b > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {contract violation in function G5<double, double>::f<double> at .*:246: c > 2(\n|\r\n|\r)} }
// { dg-output {\[continue:on\](\n|\r\n|\r)} }
// { dg-output ".assertion_kind: pre, semantic: enforce, mode: predicate_false.(\n|\r\n|\r)" }
// { dg-output {G5 full double double, f gen R(\n|\r\n|\r)} }
34 changes: 34 additions & 0 deletions gcc/testsuite/g++.dg/contracts/cpp26/vaargs.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// { dg-do run }
// { dg-options "-std=c++2a -fcontracts -fcontracts-nonattr" }
#include <stdio.h>
#include <stdarg.h>
int simple_printf(const char* fmt, ...) [[pre : fmt != 0]] [[ post r: r > 0]]
{
va_list args;
va_start(args, fmt);

while (*fmt != '\0') {
if (*fmt == 'd') {
int i = va_arg(args, int);
printf("%d\n", i);
} else if (*fmt == 'c') {
// A 'char' variable will be promoted to 'int'
// A character literal in C is already 'int' by itself
int c = va_arg(args, int);
printf("%c\n", c);
} else if (*fmt == 'f') {
double d = va_arg(args, double);
printf("%f\n", d);
}
++fmt;
}

va_end(args);

return 6;
}

int main()
{
simple_printf("dcff", 3, 'a', 1.999, 42.5);
}
16 changes: 16 additions & 0 deletions gcc/testsuite/g++.dg/contracts/cpp26/virtual_func_err.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// These tests cover various crashes found in development
// { dg-do compile }
// { dg-options "-std=c++2a -fcontracts -fcontracts-nonattr -fcontract-continuation-mode=on" }
template<typename T>
struct Base
{
virtual int f(const int a) pre(i > 5){return a;};
private:
int i = 2;
};

int Base::f(const int a) // { dg-error "used without template arguments" }
{
return a;
}

Loading