diff --git a/clang/test/BSC/pending/CallBeforeDefine.cbs b/clang/test/BSC/pending/CallBeforeDefine.cbs new file mode 100644 index 0000000000000000000000000000000000000000..c8e9187030a7ee4a8195ba39270a172de51fc0f8 --- /dev/null +++ b/clang/test/BSC/pending/CallBeforeDefine.cbs @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics +typedef struct Foo { + int a; +}Foo; + +int Foo::getA(struct Foo* this); + +int main() { + struct Foo foo; + foo.a = 42; + return foo.getA(); +} + +int Foo::getA(struct Foo* this) { + return this->a; +} \ No newline at end of file diff --git a/clang/test/BSC/pending/InstanceMemberFunc.cbs b/clang/test/BSC/pending/InstanceMemberFunc.cbs new file mode 100644 index 0000000000000000000000000000000000000000..0cdd03d421b1fc8bb5c37472477e8031b79486c7 --- /dev/null +++ b/clang/test/BSC/pending/InstanceMemberFunc.cbs @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics +typedef struct Foo{ + int a; +}Foo; + +int Foo::getA(struct Foo* this) { + return this->a; +} + +int main() { + Foo foo; + foo.a = 42; + foo.getA(); + Foo::getA(&foo); + return 0; +} \ No newline at end of file diff --git a/clang/test/BSC/pending/OverloadFunc.cbs b/clang/test/BSC/pending/OverloadFunc.cbs new file mode 100644 index 0000000000000000000000000000000000000000..442a57b87669f0d6e64a3262f570b5d01e2cfe62 --- /dev/null +++ b/clang/test/BSC/pending/OverloadFunc.cbs @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct Foo { + int a; +}; +typedef struct Foo F; + +int F::f2(F* this) { +// expected-note@-1 {{previous definition is here}} +// expected-note@-2 {{passing argument to parameter 'this' here}} + return 1; +} + +int F::f2(F* this, int a) { // expected-error {{conflicting types for 'f2'}} + return a; +} + +int main(){ + Foo foo; + foo.a = 1; + foo.f2(); + foo.f2(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'F *' (aka 'struct Foo *')}} + return 0; +} \ No newline at end of file diff --git a/clang/test/BSC/pending/StaticMemberFunc.cbs b/clang/test/BSC/pending/StaticMemberFunc.cbs new file mode 100644 index 0000000000000000000000000000000000000000..f9b2068cfd7e0f28396081e863e993c65b432786 --- /dev/null +++ b/clang/test/BSC/pending/StaticMemberFunc.cbs @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics +typedef struct Foo{ + int a; +}Foo; + +int Foo::s1() { + return 1; +} + +int Foo::s2(struct Foo* other) { + return other->a; +} + +int main() { + struct Foo x = {0}; + Foo::s1(); + Foo::s2(&x); + return 0; +} \ No newline at end of file diff --git a/clang/test/BSC/pending/ThisParamCheck1.cbs b/clang/test/BSC/pending/ThisParamCheck1.cbs new file mode 100644 index 0000000000000000000000000000000000000000..05281fbfb1fb9aa16636449232fe2c74d5e35883 --- /dev/null +++ b/clang/test/BSC/pending/ThisParamCheck1.cbs @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef struct Foo { + int a; +}Foo; + +typedef struct Bar { + int a; +}Bar; + +int Foo::getA(int b, struct Foo* this) { // expected-error {{'this' cannot be the name of a parameter}} + return this->a; +} + +int Foo::getBarA(struct Bar* this) { // expected-error {{struct Bar * is not supported on this target}} + return this->a; +} \ No newline at end of file diff --git a/clang/test/BSC/pending/ThisParamCheck2.cbs b/clang/test/BSC/pending/ThisParamCheck2.cbs new file mode 100644 index 0000000000000000000000000000000000000000..1fee3762a580a10bde21b4721bce596c6822aa77 --- /dev/null +++ b/clang/test/BSC/pending/ThisParamCheck2.cbs @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef struct Foo{ + int a; +}Foo; + +int Foo::s1() { + return 1; +} + +int Foo::s2(struct Foo* other) { + return other->a; +} + +int main() { + struct Foo x = {0}; + x.s1(); // expected-error {{no member named 's1' in 'struct Foo'; did you mean to use '::' instead of '.'?}} + + x.s2(); // expected-error {{no member named 's2' in 'struct Foo'; did you mean to use '::' instead of '.'?}} + return 0; +} \ No newline at end of file diff --git a/clang/test/BSC/pending/Typedef.cbs b/clang/test/BSC/pending/Typedef.cbs new file mode 100644 index 0000000000000000000000000000000000000000..ee779a449bcb2a6049519225f1c8aa8419980030 --- /dev/null +++ b/clang/test/BSC/pending/Typedef.cbs @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics +struct Foo { + int a; + int b; +}; +typedef struct Foo Foo; + +int Foo::getB(Foo* this) { + return this->b; +} + +int Foo::getAPlusB(struct Foo* this) { + return this->a + this->b; +} + +int main() { + Foo foo; + foo.a = 42; + foo.b = 2023; + int b = foo.getB(); + int ab = foo.getAPlusB(); + return 0; +} + diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py index 863ab444fb023766fc27438c46ef99555fb0d31a..b99a6dacb05df4720bad915eb0c2aeeade8793b4 100644 --- a/clang/test/lit.cfg.py +++ b/clang/test/lit.cfg.py @@ -26,7 +26,7 @@ config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) # suffixes: A list of file extensions to treat as test files. config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu', - '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs'] + '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs', '.cbs'] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index 4b042b525d38995c37034a7ffa6796804caceb7a..268f0d0dca450f297a110aa6f8c3d6951df4492b 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -730,4 +730,14 @@ TEST_F(CommandLineTest, DigraphsNotImplied) { ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-digraphs")))); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdigraphs")))); } + +TEST_F(CommandLineTest, DigraphsEnabled) { + const char *Args[] = {"-std=c89", "-fdigraphs"}; + + ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); + ASSERT_TRUE(Invocation.getLangOpts()->Digraphs); + + Invocation.generateCC1CommandLine(GeneratedArgs, *this); + ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdigraphs"))); +} } // anonymous namespace