diff options
Diffstat (limited to 'test/SemaCXX/enable_if.cpp')
-rw-r--r-- | test/SemaCXX/enable_if.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/test/SemaCXX/enable_if.cpp b/test/SemaCXX/enable_if.cpp index eababc34d3702..9a06d38661102 100644 --- a/test/SemaCXX/enable_if.cpp +++ b/test/SemaCXX/enable_if.cpp @@ -246,11 +246,11 @@ namespace FnPtrs { int noOvlNoCandidate(int m) __attribute__((enable_if(false, ""))); void test8() { - int (*p)(int) = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}} - int (*p2)(int) = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}} + int (*p)(int) = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' because it has one or more non-tautological enable_if conditions}} + int (*p2)(int) = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' because it has one or more non-tautological enable_if conditions}} int (*a)(int); - a = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}} - a = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}} + a = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' because it has one or more non-tautological enable_if conditions}} + a = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' because it has one or more non-tautological enable_if conditions}} } } @@ -472,3 +472,30 @@ namespace instantiate_constexpr_in_enable_if { }; void g() { X<int>().f(); } } + +namespace PR31934 { +int foo(int a) __attribute__((enable_if(a, ""))); +int runFn(int (&)(int)); + +void run() { + { + int (&bar)(int) = foo; // expected-error{{cannot take address of function 'foo'}} + int baz = runFn(foo); // expected-error{{cannot take address of function 'foo'}} + } + + { + int (&bar)(int) = (foo); // expected-error{{cannot take address of function 'foo'}} + int baz = runFn((foo)); // expected-error{{cannot take address of function 'foo'}} + } + + { + int (&bar)(int) = static_cast<int (&)(int)>(foo); // expected-error{{cannot take address of function 'foo'}} + int baz = runFn(static_cast<int (&)(int)>(foo)); // expected-error{{cannot take address of function 'foo'}} + } + + { + int (&bar)(int) = static_cast<int (&)(int)>((foo)); // expected-error{{cannot take address of function 'foo'}} + int baz = runFn(static_cast<int (&)(int)>((foo))); // expected-error{{cannot take address of function 'foo'}} + } +} +} |