reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify

// This is a test for an egregious hack in Clang that works around
// an issue with GCC's <type_traits> implementation. std::common_type
// relies on pre-standard rules for decltype(), in which it doesn't
// produce reference types so frequently.

#ifdef BE_THE_HEADER

#pragma GCC system_header
namespace std {
  template<typename T> T &&declval();

  template<typename...Ts> struct common_type {};
  template<typename A, typename B> struct common_type<A, B> {
    // Under the rules in the standard, this always produces a
    // reference type.
    typedef decltype(true ? declval<A>() : declval<B>()) type;
  };
}

#else

#define BE_THE_HEADER
#include "libstdcxx_common_type_hack.cpp"

using T = int;
using T = std::common_type<int, int>::type;

using U = int; // expected-note {{here}}
using U = decltype(true ? std::declval<int>() : std::declval<int>()); // expected-error {{different types}}

#endif