Test cases for parsing generic function calls (#175)
* Adding test files for _For_any specifier and type variable declarations. * These two files tests for parsing generic function calls and any errors that clang may encounter * Editing parsing error testing in accordance to coding changes in checkedc-clang * Moving a couple test cases to checkedc-clang since it tests for specifics of how clang is tested.
This commit is contained in:
Родитель
6a33652c9c
Коммит
281a80978d
|
@ -0,0 +1,31 @@
|
|||
// Tests to make sure generic function call is parsed correctly.
|
||||
//
|
||||
// More specifically, we are testing for below cases to parse and not error :
|
||||
// 1) When calling a generic function, type specification in <> is parsed. We
|
||||
// do not yet care whether the number of type variables in function
|
||||
// declaration is consistent with number of types specified in function call
|
||||
// 2) An expression that may be ambiguous to generic function call is a
|
||||
// comparison expression. ex) foo < bar; Make sure this isn't going to break
|
||||
//
|
||||
// RUN: %clang_cc1 -fcheckedc-extension -verify %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
_For_any(T) T foo(T a, T b) {
|
||||
T a;
|
||||
return a;
|
||||
}
|
||||
|
||||
void bar() {
|
||||
return;
|
||||
}
|
||||
|
||||
void callPolymorphicTypes() {
|
||||
void *x, *y;
|
||||
// This line tests that the compiler is parsing generic function call.
|
||||
foo<void*>(x, y);
|
||||
// This line tests that the compiler is parsing non generic function call.
|
||||
bar();
|
||||
int a, b;
|
||||
// This line tests that the compiler parses comparison not generic function
|
||||
if (a < b) {};
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// Tests to make sure generic function call errors are parsed correctly.
|
||||
//
|
||||
// Make sure that syntatic error in calling generic functions are handled
|
||||
//
|
||||
// RUN: %clang_cc1 -fcheckedc-extension -verify %s
|
||||
|
||||
_For_any(T) T Foo(T a, T b) {
|
||||
T a;
|
||||
return a;
|
||||
}
|
||||
|
||||
void CallGenericFunction() {
|
||||
void *x, *y;
|
||||
Foo<void* unsigned int>(x, y); //expected-error{{expected , or >}}
|
||||
Foo<void*, >(x, y); //expected-error{{expected a type}}
|
||||
Foo<, , >(x, y); //expected-error{{expected a type}}
|
||||
Foo(x, y); //expected-error{{expected a list of type arguments for a generic function}}
|
||||
}
|
Загрузка…
Ссылка в новой задаче