diff options
Diffstat (limited to 'test/SemaCXX/attr-unavailable.cpp')
-rw-r--r-- | test/SemaCXX/attr-unavailable.cpp | 85 |
1 files changed, 59 insertions, 26 deletions
diff --git a/test/SemaCXX/attr-unavailable.cpp b/test/SemaCXX/attr-unavailable.cpp index bafae2ab43..c5c3cff6bc 100644 --- a/test/SemaCXX/attr-unavailable.cpp +++ b/test/SemaCXX/attr-unavailable.cpp @@ -1,17 +1,16 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -int &foo(int); // expected-note {{candidate}} -double &foo(double); // expected-note {{candidate}} -void foo(...) __attribute__((__unavailable__)); // expected-note {{candidate function}} \ -// expected-note{{'foo' has been explicitly marked unavailable here}} +int &foo(int); +double &foo(double); +void foo(...) __attribute__((__unavailable__)); // \ +// expected-note 2 {{'foo' has been explicitly marked unavailable here}} -void bar(...) __attribute__((__unavailable__)); // expected-note 2{{explicitly marked unavailable}} \ - // expected-note 2{{candidate function has been explicitly made unavailable}} +void bar(...) __attribute__((__unavailable__)); // expected-note 4 {{explicitly marked unavailable}} void test_foo(short* sp) { int &ir = foo(1); double &dr = foo(1.0); - foo(sp); // expected-error{{call to unavailable function 'foo'}} + foo(sp); // expected-error{{'foo' is unavailable}} void (*fp)(...) = &bar; // expected-error{{'bar' is unavailable}} void (*fp2)(...) = bar; // expected-error{{'bar' is unavailable}} @@ -24,9 +23,9 @@ namespace radar9046492 { // rdar://9046492 #define FOO __attribute__((unavailable("not available - replaced"))) -void foo() FOO; // expected-note {{candidate function has been explicitly made unavailable}} +void foo() FOO; // expected-note{{'foo' has been explicitly marked unavailable here}} void bar() { - foo(); // expected-error {{call to unavailable function 'foo': not available - replaced}} + foo(); // expected-error {{'foo' is unavailable: not available - replaced}} } } @@ -79,19 +78,19 @@ void untemplated_marked(UnavailableClass &UC) __attribute__((unavailable)) { } template <class T> void templated_calls_bar() { bar(); } // \ - // expected-error{{call to unavailable function 'bar'}} + // expected-error{{'bar' is unavailable}} template <class T> void templated_calls_bar_arg(T v) { bar(v); } // \ - // expected-error{{call to unavailable function 'bar'}} + // expected-error{{'bar' is unavailable}} template <class T> void templated_calls_bar_arg_never_called(T v) { bar(v); } template <class T> -void unavail_templated_calls_bar() __attribute__((unavailable)) { // \ - expected-note{{candidate function [with T = int] has been explicitly made unavailable}} +void unavail_templated_calls_bar() __attribute__((unavailable)) { // \ +// expected-note {{'unavail_templated_calls_bar<int>' has been explicitly marked unavailable here}} bar(5); } template <class T> -void unavail_templated_calls_bar_arg(T v) __attribute__((unavailable)) { // \ - expected-note{{candidate function [with T = int] has been explicitly made unavailable}} +void unavail_templated_calls_bar_arg(T v) __attribute__((unavailable)) { +// expected-note@-1 {{'unavail_templated_calls_bar_arg<int>' has been explicitly marked unavailable here}} bar(v); } @@ -102,34 +101,34 @@ void calls_templates_which_call_bar() { expected-note{{in instantiation of function template specialization 'templated_calls_bar_arg<int>' requested here}} unavail_templated_calls_bar<int>(); // \ - expected-error{{call to unavailable function 'unavail_templated_calls_bar'}} + expected-error{{'unavail_templated_calls_bar<int>' is unavailable}} unavail_templated_calls_bar_arg(5); // \ - expected-error{{call to unavailable function 'unavail_templated_calls_bar_arg'}} + expected-error{{'unavail_templated_calls_bar_arg<int>' is unavailable}} } -template <class T> void unavail_templated(T) __attribute__((unavailable)); // \ - expected-note{{candidate function [with T = int] has been explicitly made unavailable}} +template <class T> void unavail_templated(T) __attribute__((unavailable)); +// expected-note@-1 {{'unavail_templated<int>' has been explicitly marked unavailable here}} void calls_unavail_templated() { - unavail_templated(5); // expected-error{{call to unavailable function 'unavail_templated'}} + unavail_templated(5); // expected-error{{'unavail_templated<int>' is unavailable}} } void unavail_calls_unavail_templated() __attribute__((unavailable)) { unavail_templated(5); } -void unavailable() __attribute((unavailable)); // \ - expected-note 4{{candidate function has been explicitly made unavailable}} +void unavailable() __attribute((unavailable)); +// expected-note@-1 4 {{'unavailable' has been explicitly marked unavailable here}} struct AvailableStruct { void calls_unavailable() { unavailable(); } // \ - expected-error{{call to unavailable function 'unavailable'}} + expected-error{{'unavailable' is unavailable}} template <class U> void calls_unavailable() { unavailable(); } // \ - expected-error{{call to unavailable function 'unavailable'}} + expected-error{{'unavailable' is unavailable}} }; template <class T> struct AvailableStructTemplated { void calls_unavailable() { unavailable(); } // \ - expected-error{{call to unavailable function 'unavailable'}} + expected-error{{'unavailable' is unavailable}} template <class U> void calls_unavailable() { unavailable(); } // \ - expected-error{{call to unavailable function 'unavailable'}} + expected-error{{'unavailable' is unavailable}} }; struct __attribute__((unavailable)) UnavailableStruct { void calls_unavailable() { unavailable(); } @@ -139,3 +138,37 @@ template <class T> struct __attribute__((unavailable)) UnavailableStructTemplate void calls_unavailable() { unavailable(); } template <class U> void calls_unavailable() { unavailable(); } }; + +int unavailable_int() __attribute__((unavailable)); // expected-note 2 {{'unavailable_int' has been explicitly marked unavailable here}} +int has_default_arg(int x = unavailable_int()) { // expected-error{{'unavailable_int' is unavailable}} + return x; +} + +int has_default_arg2(int x = unavailable_int()) __attribute__((unavailable)) { + return x; +} + +template <class T> +T unavailable_template() __attribute__((unavailable)); +// expected-note@-1 {{'unavailable_template<int>' has been explicitly marked unavailable here}} + +template <class T> +int has_default_arg_template(T x = unavailable_template<T>()) {} +// expected-error@-1 {{'unavailable_template<int>' is unavailable}} + +int instantiate_it = has_default_arg_template<int>(); +// expected-note@-1 {{in instantiation of default function argument expression for 'has_default_arg_template<int>' required here}} + +template <class T> +int has_default_arg_template2(T x = unavailable_template<T>()) + __attribute__((unavailable)) {} + +__attribute__((unavailable)) +int instantiate_it2 = has_default_arg_template2<int>(); + +template <class T> +int phase_one_unavailable(int x = unavailable_int()) {} +// expected-error@-1 {{'unavailable_int' is unavailable}} + +template <class T> +int phase_one_unavailable2(int x = unavailable_int()) __attribute__((unavailable)) {} |