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/SemaCXX/builtins.cpp | |
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/SemaCXX/builtins.cpp')
-rw-r--r-- | clang/test/SemaCXX/builtins.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
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}} +} |