1// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify 2 3// This is a test for an egregious hack in Clang that works around 4// an issue with libstdc++-4.2's <tr1/hashtable> implementation. 5// The code in question returns 'false' from a function with a pointer 6// return type, which is ill-formed in C++11. 7 8#ifdef BE_THE_HEADER 9 10#pragma GCC system_header 11namespace std { 12 namespace tr1 { 13 template<typename T> struct hashnode; 14 template<typename T> struct hashtable { 15 typedef hashnode<T> node; 16 node *find_node() { 17 // This is ill-formed in C++11, per core issue 903, but we accept 18 // it anyway in a system header. 19 return false; 20 } 21 }; 22 } 23} 24 25#else 26 27#define BE_THE_HEADER 28#include "libstdcxx_pointer_return_false_hack.cpp" 29 30auto *test1 = std::tr1::hashtable<int>().find_node(); 31 32void *test2() { return false; } // expected-error {{cannot initialize}} 33 34#endif 35