diff --git a/regression/cbmc-cpp/Makefile b/regression/cbmc-cpp/Makefile index bf0682a5381..486a8c750f7 100644 --- a/regression/cbmc-cpp/Makefile +++ b/regression/cbmc-cpp/Makefile @@ -1,10 +1,10 @@ default: tests.log test: - @../test.pl -c ../../../src/cbmc/cbmc + @../test.pl -p -c ../../../src/cbmc/cbmc tests.log: ../test.pl - @../test.pl -c ../../../src/cbmc/cbmc + @../test.pl -p -c ../../../src/cbmc/cbmc show: @for dir in *; do \ diff --git a/regression/cbmc-cpp/MethodParam1/main.cpp b/regression/cbmc-cpp/MethodParam1/main.cpp index 78240ce8bd2..bb6db1cb9eb 100644 --- a/regression/cbmc-cpp/MethodParam1/main.cpp +++ b/regression/cbmc-cpp/MethodParam1/main.cpp @@ -2,6 +2,7 @@ unsigned x; class ct { +public: void f(int i) { x=x+i; } diff --git a/regression/cpp/Method_qualifier1/main.cpp b/regression/cpp/Method_qualifier1/main.cpp index 33479b6ee6d..e06e5f0081c 100644 --- a/regression/cpp/Method_qualifier1/main.cpp +++ b/regression/cpp/Method_qualifier1/main.cpp @@ -1,4 +1,4 @@ -#include +#include class my_class { diff --git a/regression/cpp/auto1/main.cpp b/regression/cpp/auto1/main.cpp index 7d5fa793630..7463a819e8b 100644 --- a/regression/cpp/auto1/main.cpp +++ b/regression/cpp/auto1/main.cpp @@ -1,4 +1,4 @@ -#include +#include const auto i=1; diff --git a/regression/cpp/deleted_function1/main.cpp b/regression/cpp/deleted_function1/main.cpp new file mode 100644 index 00000000000..da152f741ad --- /dev/null +++ b/regression/cpp/deleted_function1/main.cpp @@ -0,0 +1,19 @@ +class A +{ +public: + void foo() {} +}; + +class B : public A +{ +public: + void foo() = delete; +}; + +int main() +{ + B b; + b.foo(); + + return 0; +} diff --git a/regression/cpp/deleted_function1/test.desc b/regression/cpp/deleted_function1/test.desc new file mode 100644 index 00000000000..6eedb7b82a7 --- /dev/null +++ b/regression/cpp/deleted_function1/test.desc @@ -0,0 +1,8 @@ +CORE +main.cpp +-std=c++11 +^EXIT=(64|1)$ +^SIGNAL=0$ +not accessible +-- +^warning: ignoring diff --git a/regression/cpp/switch1/main.cpp b/regression/cpp/switch1/main.cpp index 873f8fcdff1..b53937bb70e 100644 --- a/regression/cpp/switch1/main.cpp +++ b/regression/cpp/switch1/main.cpp @@ -1,4 +1,4 @@ -#include +#include int main() { diff --git a/regression/systemc/Array1/main.cpp b/regression/systemc/Array1/main.cpp index aa6f4492308..238a53ac0b0 100644 --- a/regression/systemc/Array1/main.cpp +++ b/regression/systemc/Array1/main.cpp @@ -1,4 +1,4 @@ -#include +#include #define COPY diff --git a/regression/systemc/Array2/main.cpp b/regression/systemc/Array2/main.cpp index 430ecce52b7..d3969afdaa9 100644 --- a/regression/systemc/Array2/main.cpp +++ b/regression/systemc/Array2/main.cpp @@ -1,4 +1,4 @@ -#include +#include class myarray { diff --git a/regression/systemc/Array3/main.cpp b/regression/systemc/Array3/main.cpp index 3da119c53e5..07d379a40a8 100644 --- a/regression/systemc/Array3/main.cpp +++ b/regression/systemc/Array3/main.cpp @@ -1,4 +1,4 @@ -#include +#include #define FUNCTION diff --git a/regression/systemc/Array4/main.cpp b/regression/systemc/Array4/main.cpp index 73763c3b5ee..4726e5a5b10 100644 --- a/regression/systemc/Array4/main.cpp +++ b/regression/systemc/Array4/main.cpp @@ -1,4 +1,4 @@ -#include +#include #define CLASS diff --git a/regression/systemc/BitvectorCpp1/main.cpp b/regression/systemc/BitvectorCpp1/main.cpp index 858aab0b5db..0601e154ebc 100644 --- a/regression/systemc/BitvectorCpp1/main.cpp +++ b/regression/systemc/BitvectorCpp1/main.cpp @@ -1,4 +1,4 @@ -#include +#include int main(int argc, char** argv) { diff --git a/regression/systemc/BitvectorCpp2/main.cpp b/regression/systemc/BitvectorCpp2/main.cpp index 0b8f423136b..96dc9493076 100644 --- a/regression/systemc/BitvectorCpp2/main.cpp +++ b/regression/systemc/BitvectorCpp2/main.cpp @@ -1,4 +1,4 @@ -#include +#include int main(int argc, char** argv) { diff --git a/regression/systemc/This1/main.cpp b/regression/systemc/This1/main.cpp index d6a9a7a21e2..419088a0973 100644 --- a/regression/systemc/This1/main.cpp +++ b/regression/systemc/This1/main.cpp @@ -1,4 +1,4 @@ -#include +#include class Foo; diff --git a/src/ansi-c/scanner.l b/src/ansi-c/scanner.l index b4468567c4b..3347da370ee 100644 --- a/src/ansi-c/scanner.l +++ b/src/ansi-c/scanner.l @@ -749,8 +749,18 @@ and { return cpp98_keyword(TOK_ANDAND); } and_eq { return cpp98_keyword(TOK_ANDASSIGN); } bool { return cpp98_keyword(TOK_BOOL); } catch { return cpp98_keyword(TOK_CATCH); } -char16_t { return cpp11_keyword(TOK_CHAR16_T); } // C++11 -char32_t { return cpp11_keyword(TOK_CHAR32_T); } // C++11 +char16_t { // C++11, but Visual Studio uses typedefs + if(PARSER.mode == configt::ansi_ct::flavourt::VISUAL_STUDIO) + return make_identifier(); + else + return cpp11_keyword(TOK_CHAR16_T); + } +char32_t { // C++11, but Visual Studio uses typedefs + if(PARSER.mode == configt::ansi_ct::flavourt::VISUAL_STUDIO) + return make_identifier(); + else + return cpp11_keyword(TOK_CHAR32_T); + } class { return cpp98_keyword(TOK_CLASS); } compl { return cpp98_keyword('~'); } constexpr { return cpp11_keyword(TOK_CONSTEXPR); } // C++11 diff --git a/src/cpp/cpp_typecheck_compound_type.cpp b/src/cpp/cpp_typecheck_compound_type.cpp index 82f64089595..7c96baeb402 100644 --- a/src/cpp/cpp_typecheck_compound_type.cpp +++ b/src/cpp/cpp_typecheck_compound_type.cpp @@ -450,6 +450,14 @@ void cpp_typecheckt::typecheck_compound_declarator( if(is_method) { + if( + value.id() == ID_code && + to_code(value).get_statement() == ID_cpp_delete) + { + value.make_nil(); + component.set(ID_access, "noaccess"); + } + component.set(ID_is_inline, declaration.member_spec().is_inline()); // the 'virtual' name of the function @@ -1487,13 +1495,11 @@ bool cpp_typecheckt::get_component( } else { - #if 0 error().source_location=source_location; - str << "error: member `" << component_name - << "' is not accessible (" << component.get(ID_access) << ")"; - str << "\nstruct name: " << final_type.get(ID_name); + error() << "error: member `" << component_name + << "' is not accessible (" << component.get(ID_access) << ")" + << eom; throw 0; - #endif } } @@ -1523,12 +1529,10 @@ bool cpp_typecheckt::get_component( { if(check_component_access(component, final_type)) { - #if 0 error().source_location=source_location; - str << "error: member `" << component_name - << "' is not accessible"; + error() << "error: member `" << component_name + << "' is not accessible" << eom; throw 0; - #endif } if(object.get_bool(ID_C_lvalue)) diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index fce70bcfa72..b19299909c9 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -2494,6 +2494,12 @@ bool Parser::rConstructorDecl( case TOK_DEFAULT: // C++0x { + if(!ansi_c_parser.cpp11) + { + SyntaxError(); + return false; + } + constructor.value()=codet(ID_default); set_location(constructor.value(), value); } @@ -2501,6 +2507,12 @@ bool Parser::rConstructorDecl( case TOK_DELETE: // C++0x { + if(!ansi_c_parser.cpp11) + { + SyntaxError(); + return false; + } + constructor.value()=codet(ID_cpp_delete); set_location(constructor.value(), value); } @@ -2675,12 +2687,24 @@ bool Parser::rDeclaratorWithInit( if(lex.LookAhead(0)==TOK_DEFAULT) // C++0x { + if(!ansi_c_parser.cpp11) + { + SyntaxError(); + return false; + } + lex.get_token(tk); declarator.value()=codet(ID_default); set_location(declarator.value(), tk); } else if(lex.LookAhead(0)==TOK_DELETE) // C++0x { + if(!ansi_c_parser.cpp11) + { + SyntaxError(); + return false; + } + lex.get_token(tk); declarator.value()=codet(ID_cpp_delete); set_location(declarator.value(), tk); diff --git a/src/util/config.cpp b/src/util/config.cpp index 521c1b7dbad..98b30aef564 100644 --- a/src/util/config.cpp +++ b/src/util/config.cpp @@ -663,7 +663,11 @@ configt::cppt::cpp_standardt configt::cppt::default_cpp_standard() // g++ 6.3 uses gnu++14 // g++ 5.4 uses gnu++98 // clang 6.0 uses c++14 + #if defined _WIN32 + return cpp_standardt::CPP14; + #else return cpp_standardt::CPP98; + #endif } void configt::set_arch(const irep_idt &arch)