diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index e711ea022f1b473d83e66769b3e36750360fcff6..4feb552a2fd111f4d9c45047b027090b06809654 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1634,11 +1634,8 @@ ExprResult Parser::ParseCastExpression( ParseKind, isAddressOfOperand, NotCastExpr, isTypeCast, isVectorLiteral, NotPrimaryExpression, HasBSCScopeSpec); } - // Enter the type-cast check in bsc generic. - if (!(getLangOpts().CPlusPlus || getLangOpts().BSC)) { -#else - if (!getLangOpts().CPlusPlus) { #endif + if (!getLangOpts().CPlusPlus) { Diag(Tok, diag::err_expected_expression); return ExprError(); } diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 5e61accf119becb78eb5b64d8e7a967d4e5da989..caa799abb883d1f92d0734ec730ddb7433bfa2f7 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -275,9 +275,6 @@ Default: llvm::all_of(GNUAttrs, IsStmtAttr); // FIXME: if-cond is too complex here. if ((getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt || -#if ENABLE_BSC - getLangOpts().BSC || -#endif (StmtCtx & ParsedStmtContext::AllowDeclarationsInC) != ParsedStmtContext()) && ((GNUAttributeLoc.isValid() && !(HaveAttrs && AllAttrsAreStmtAttrs)) || diff --git a/clang/test/BSC/Negative/Generic/StructAndFunction/cast_struct_to_int/cast_struct_to_int.cbs b/clang/test/BSC/Negative/Generic/StructAndFunction/cast_struct_to_int/cast_struct_to_int.cbs index 6f503faf71fb32b40ee655eac3dc7fbabba6503d..6a47ab02790ee12960cc9858ddce9c691b5a5bf8 100644 --- a/clang/test/BSC/Negative/Generic/StructAndFunction/cast_struct_to_int/cast_struct_to_int.cbs +++ b/clang/test/BSC/Negative/Generic/StructAndFunction/cast_struct_to_int/cast_struct_to_int.cbs @@ -2,7 +2,7 @@ T1 foo (T1 a, T2 b) { - int x = int(b); // expected-error {{operand of type 'struct S' where arithmetic or pointer type is required}} + int x = (int) b; // expected-error {{operand of type 'struct S' where arithmetic or pointer type is required}} return x; } diff --git a/clang/test/BSC/Negative/Others/control_flow_graph/backward_goto_2/backward_goto_2.cbs b/clang/test/BSC/Negative/Others/control_flow_graph/backward_goto_2/backward_goto_2.cbs index aeb568683bd0278b72ac781dab96761bd76ed3b5..e41687c793ff78186bccf8a7aba6c5f2c936f791 100644 --- a/clang/test/BSC/Negative/Others/control_flow_graph/backward_goto_2/backward_goto_2.cbs +++ b/clang/test/BSC/Negative/Others/control_flow_graph/backward_goto_2/backward_goto_2.cbs @@ -7,9 +7,9 @@ void test1(int *owned p, int x) { for (int i = 0; i < 10; i++) { x = x + i; } - -L1: - void *temp = (void *)(void *owned)p; +L1:{ + void *temp = (void *)(void *owned)p; + } } // bad cfg diff --git a/clang/test/BSC/Negative/Others/control_flow_graph/structured_control_flow_1/structured_control_flow_1.cbs b/clang/test/BSC/Negative/Others/control_flow_graph/structured_control_flow_1/structured_control_flow_1.cbs index 675aeb488ba292bf0173c8c08add81477bbc51b4..fdea1a36b616f72f6d47a513f505abdabfe689a9 100644 --- a/clang/test/BSC/Negative/Others/control_flow_graph/structured_control_flow_1/structured_control_flow_1.cbs +++ b/clang/test/BSC/Negative/Others/control_flow_graph/structured_control_flow_1/structured_control_flow_1.cbs @@ -35,10 +35,11 @@ int test3(){ goto FAIL; } return 0; -FAIL: - int x2 = 0; - int *owned p2 = (int *owned)&x2; - return 1; //expected-error {{memory leak of value: `p2`}} +FAIL:{ + int x2 = 0; + int *owned p2 = (int *owned)&x2; + return 1; //expected-error {{memory leak of value: `p2`}} + } } int g_a = 0; @@ -51,8 +52,9 @@ int test4() { goto next; // expected-error {{memory leak of value: `p1`}} } int v = 3; -next: - int x2 = 0; - int *owned p2 = (int *owned)&x2; - return 0; // expected-error {{memory leak of value: `p2`}} +next:{ + int x2 = 0; + int *owned p2 = (int *owned)&x2; + return 0; // expected-error {{memory leak of value: `p2`}} + } } \ No newline at end of file diff --git a/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/cstyle_cast.cbs b/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/cstyle_cast.cbs new file mode 100644 index 0000000000000000000000000000000000000000..8d7b550d399c2455054648d923e2edec5dbf95b5 --- /dev/null +++ b/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/cstyle_cast.cbs @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify %s +void test1(void){ + int A = int(42);// expected-error {{expected expression}} +} + +int test2(float a, float b) { + int x = int(a) + int(b);// expected-error {{expected expression}} + return x; +} + +int test3(float a, float b) { + int x = int();// expected-error {{expected expression}} + a = (float) x; + return x; +} \ No newline at end of file diff --git a/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/decl_forbidden.cbs b/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/decl_forbidden.cbs new file mode 100644 index 0000000000000000000000000000000000000000..0473fbd594cfab9a5e0ab36f2da1f0a33e0b6600 --- /dev/null +++ b/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/decl_forbidden.cbs @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -verify %s + +void test1(int x){ + switch(x){ + case 0: + int a=0;// expected-error {{expected expression}} + break; + default:{ + int a =0;//benign + } + } +} + +int test2(int x) { + if(x>10){ + goto label0; + }else if(x<100){ + goto label1; + } + int a; + goto label2; +label0: + int b=0;// expected-error {{expected expression}} + return 0; + +label1:{ + int b=0;// benign + return a; +} +label2: + a+=1; + return a;// benign +} + +int test3(void) { + int a=0; + if(a>0) + int b=0;// expected-error {{expected expression}} + while(a>0) + int b=0;// expected-error {{expected expression}} + for(;;) + int b=0;// expected-error {{expected expression}} +} \ No newline at end of file diff --git a/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/example.cbs b/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/example.cbs new file mode 100644 index 0000000000000000000000000000000000000000..8d7b550d399c2455054648d923e2edec5dbf95b5 --- /dev/null +++ b/clang/test/BSC/Negative/Others/cpp_have_but_cbs_not/example.cbs @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify %s +void test1(void){ + int A = int(42);// expected-error {{expected expression}} +} + +int test2(float a, float b) { + int x = int(a) + int(b);// expected-error {{expected expression}} + return x; +} + +int test3(float a, float b) { + int x = int();// expected-error {{expected expression}} + a = (float) x; + return x; +} \ No newline at end of file diff --git a/clang/test/BSC/Positive/Coroutine/Other/DifferenctReturnType/async-type-with-pointer/async-type-with-pointer.cbs b/clang/test/BSC/Positive/Coroutine/Other/DifferenctReturnType/async-type-with-pointer/async-type-with-pointer.cbs index 10829903686573f5eb4221cf87d1e8224e932d22..ab89b5afab6dbfe15f19f9690d024b147b8066a9 100644 --- a/clang/test/BSC/Positive/Coroutine/Other/DifferenctReturnType/async-type-with-pointer/async-type-with-pointer.cbs +++ b/clang/test/BSC/Positive/Coroutine/Other/DifferenctReturnType/async-type-with-pointer/async-type-with-pointer.cbs @@ -18,8 +18,9 @@ async int* f() { int* b = &a; int c; if(a == 1) { - if (*b == 3) - int c = await read(3); + if (*b == 3){ + int c = await read(3); + } int c = await read(2); } int* d = &c; diff --git a/clang/test/BSC/Positive/Generic/StructAndFunction/cast_in_generic_body/cast_in_generic_body.cbs b/clang/test/BSC/Positive/Generic/StructAndFunction/cast_in_generic_body/cast_in_generic_body.cbs index 39794f324fe4de435a0d497026682245df274980..6f0b6bf3c67b94c9a680021c5c497d432107bac7 100644 --- a/clang/test/BSC/Positive/Generic/StructAndFunction/cast_in_generic_body/cast_in_generic_body.cbs +++ b/clang/test/BSC/Positive/Generic/StructAndFunction/cast_in_generic_body/cast_in_generic_body.cbs @@ -4,7 +4,7 @@ int foo (T a, T b) { - int x = int(a) + int(b); // this should report error + int x = (int)a + (int)b; // this should report error return x; } diff --git a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-for.cbs b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-for.cbs index 54f75711edfd604800416ee55967ddf69394d150..fde9026572637b549b1702af509990cec020ad0b 100644 --- a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-for.cbs +++ b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-for.cbs @@ -24,8 +24,9 @@ int test_for() { int test_for1() { int n = 1; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++){ A aaa = {}; + } return 0; } diff --git a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-else-if-no-compoundstmt.cbs b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-else-if-no-compoundstmt.cbs index e7a5f0c45d00b9d74f42870e1641aeee67389850..b7cb687b56cc1aae286df8d0ed74f06b1c08d541 100644 --- a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-else-if-no-compoundstmt.cbs +++ b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-else-if-no-compoundstmt.cbs @@ -13,20 +13,25 @@ public: } }; int foo() { - if (0) - S s1 = {}; - else if (1) - S s1 = {}; + if (0) { + S s1 = {}; + } + else if (1){ + S s1 = {}; + } return 0; } int goo() { - if (0) - S s1 = {}; - else if (0) - S s1 = {}; - else - S s1 = {}; + if (0) { + S s1 = {}; + } + else if (0){ + S s1 = {}; + } + else { + S s1 = {}; + } return 0; } diff --git a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-1.cbs b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-1.cbs index 0de6270d1ed6837f5112cf6d117bb243ca65cb21..233458b8f9443ab7d64f219e845c5ac6cc248221 100644 --- a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-1.cbs +++ b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-1.cbs @@ -19,8 +19,9 @@ int foo() { } if (1) - if (1) + if (1){ S s1 = {}; + } return 0; } @@ -28,8 +29,9 @@ int goo() { if (0) { S s1 = {}; } else if (0) - if (1) + if (1){ S s1 = {}; + } return 0; diff --git a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-2.cbs b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-2.cbs index c7dd80ea5f7253cfbb44367e8deb758e325b1676..922927508229f780bb307a2baf60d0a5baa1a2a7 100644 --- a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-2.cbs +++ b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-2.cbs @@ -19,8 +19,9 @@ int foo() { } if (1) - if (1) + if (1){ S s1 = {}; + } return 0; } @@ -28,8 +29,9 @@ int goo() { if (0) { S s1 = {}; } else if (0) - if (1) + if (1){ S s1 = {}; + } return 0; } diff --git a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-part-compoundstmt.cbs b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-part-compoundstmt.cbs index a38ccac6ee73501d61a509ce4a19bbdbe29430f5..1360b85eb4ffc020cb7619b9b3fc12cf175421fc 100644 --- a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-part-compoundstmt.cbs +++ b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/destructor-if-else-part-compoundstmt.cbs @@ -12,8 +12,9 @@ public: } }; int foo() { - if (1) + if (1) { S s1 = {}; + } else if (0) { S s1 = {}; } @@ -25,8 +26,9 @@ int goo() { S s1 = {}; } else if (0) { S s1 = {}; - } else + } else { S s1 = {}; + } return 0; } diff --git a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/genberic-owned-struct-destructor-else-if-no-compoundstmt.cbs b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/genberic-owned-struct-destructor-else-if-no-compoundstmt.cbs index e63693c7d4da717b6fdd0ef0e723f2791dbfd7ee..10409c9edd3e51cfc418da9c7ff8999e0832c579 100644 --- a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/genberic-owned-struct-destructor-else-if-no-compoundstmt.cbs +++ b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/genberic-owned-struct-destructor-else-if-no-compoundstmt.cbs @@ -12,20 +12,25 @@ public: } }; int foo() { - if (0) + if (0) { S s1 = {}; - else if (1) + } + else if (1) { S s1 = {}; + } return 0; } int goo() { - if (0) + if (0) { S s1 = {}; - else if (0) + } + else if (0){ S s1 = {}; - else + } + else { S s1 = {}; + } return 0; } diff --git a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/generic-owned-struct-destructor-if-else-part-compoundstmt.cbs b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/generic-owned-struct-destructor-if-else-part-compoundstmt.cbs index 8812f511a934d837bb6bd1ace0f4286b8b5426d5..58d09e5f1ba54bcc711c101c7ab49907421379ef 100644 --- a/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/generic-owned-struct-destructor-if-else-part-compoundstmt.cbs +++ b/clang/test/BSC/Positive/OwnedStruct/Destructor/destructor-if/generic-owned-struct-destructor-if-else-part-compoundstmt.cbs @@ -12,9 +12,9 @@ public: } }; int foo() { - if (1) + if (1){ S s1 = {}; - else if (0) { + } else if (0) { S s1 = {}; } return 0; @@ -25,9 +25,9 @@ int goo() { S s1 = {}; } else if (0) { S s1 = {}; - } else + } else { S s1 = {}; - + } return 0; } int main() {