diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2012-08-31 00:14:07 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2012-08-31 00:14:07 +0000 |
| commit | 34866c7719f893c957d93f5918f760b6edebd6be (patch) | |
| tree | 99993f8a0fe6978857272dddd3dfe01dd77f876c /clang/test | |
| parent | 98cfa1044fdcaaa53625c16bb9a246e0b15f7653 (diff) | |
| download | bcm5719-llvm-34866c7719f893c957d93f5918f760b6edebd6be.tar.gz bcm5719-llvm-34866c7719f893c957d93f5918f760b6edebd6be.zip | |
Change the representation of builtin functions in the AST
(__builtin_* etc.) so that it isn't possible to take their address.
Specifically, introduce a new type to represent a reference to a builtin
function, and a new cast kind to convert it to a function pointer in the
operand of a call. Fixes PR13195.
llvm-svn: 162962
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGenCXX/builtins.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Parser/builtin_classify_type.c | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/builtins.cpp | 13 |
3 files changed, 14 insertions, 13 deletions
diff --git a/clang/test/CodeGenCXX/builtins.cpp b/clang/test/CodeGenCXX/builtins.cpp index 4542563717a..0629c31015c 100644 --- a/clang/test/CodeGenCXX/builtins.cpp +++ b/clang/test/CodeGenCXX/builtins.cpp @@ -7,15 +7,3 @@ int main() { // CHECK: call signext i8 @memmove() return memmove(); } - -// <rdar://problem/10063539> - -template<int (*Compare)(const char *s1, const char *s2)> -int equal(const char *s1, const char *s2) { - return Compare(s1, s2) == 0; -} - -// CHECK: define weak_odr i32 @_Z5equalIXadL_Z16__builtin_strcmpPKcS1_EEEiS1_S1_ -// CHECK: call i32 @strcmp -template int equal<&__builtin_strcmp>(const char*, const char*); - diff --git a/clang/test/Parser/builtin_classify_type.c b/clang/test/Parser/builtin_classify_type.c index a7c08555c90..ff483b20974 100644 --- a/clang/test/Parser/builtin_classify_type.c +++ b/clang/test/Parser/builtin_classify_type.c @@ -10,7 +10,7 @@ int main() { static int ary[__builtin_classify_type(a)]; static int ary2[(__builtin_classify_type)(a)]; // expected-error{{variable length array declaration can not have 'static' storage duration}} - static int ary3[(*__builtin_classify_type)(a)]; // expected-error{{variable length array declaration can not have 'static' storage duration}} + static int ary3[(*__builtin_classify_type)(a)]; // expected-error{{builtin functions must be directly called}} int result; diff --git a/clang/test/SemaCXX/builtins.cpp b/clang/test/SemaCXX/builtins.cpp index 568ba5dde12..6b055cff640 100644 --- a/clang/test/SemaCXX/builtins.cpp +++ b/clang/test/SemaCXX/builtins.cpp @@ -7,3 +7,16 @@ void f() { } void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); } + +// <rdar://problem/10063539> +template<int (*Compare)(const char *s1, const char *s2)> +int equal(const char *s1, const char *s2) { + return Compare(s1, s2) == 0; +} +// FIXME: Our error recovery here sucks +template int equal<&__builtin_strcmp>(const char*, const char*); // expected-error {{builtin functions must be directly called}} expected-error {{expected unqualified-id}} expected-error {{expected ')'}} expected-note {{to match this '('}} + +// PR13195 +void f2() { + __builtin_isnan; // expected-error {{builtin functions must be directly called}} +} |

