Home | History | Annotate | Download | only in Lexer
      1 // RUN: %clang_cc1 -std=c++98 -verify %s
      2 // RUN: %clang_cc1 -std=c++11 -verify %s
      3 // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s
      4 // RUN: %clang_cc1 -std=c++14 -fsized-deallocation -verify %s
      5 // RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s
      6 // RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
      7 // RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s
      8 
      9 // expected-no-diagnostics
     10 
     11 // FIXME using `defined` in a macro has undefined behavior.
     12 #if __cplusplus < 201103L
     13 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
     14 #elif __cplusplus < 201402L
     15 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
     16 #elif __cplusplus < 201406L
     17 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
     18 #else
     19 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
     20 #endif
     21 
     22 #if check(binary_literals, 0, 0, 201304, 201304)
     23 #error "wrong value for __cpp_binary_literals"
     24 #endif
     25 
     26 #if check(digit_separators, 0, 0, 201309, 201309)
     27 #error "wrong value for __cpp_digit_separators"
     28 #endif
     29 
     30 #if check(init_captures, 0, 0, 201304, 201304)
     31 #error "wrong value for __cpp_init_captures"
     32 #endif
     33 
     34 #if check(generic_lambdas, 0, 0, 201304, 201304)
     35 #error "wrong value for __cpp_generic_lambdas"
     36 #endif
     37 
     38 #if check(sized_deallocation, 0, 0, 201309, 201309)
     39 #error "wrong value for __cpp_sized_deallocation"
     40 #endif
     41 
     42 #if check(constexpr, 0, 200704, 201304, 201304)
     43 #error "wrong value for __cpp_constexpr"
     44 #endif
     45 
     46 #if check(decltype_auto, 0, 0, 201304, 201304)
     47 #error "wrong value for __cpp_decltype_auto"
     48 #endif
     49 
     50 #if check(return_type_deduction, 0, 0, 201304, 201304)
     51 #error "wrong value for __cpp_return_type_deduction"
     52 #endif
     53 
     54 #if check(runtime_arrays, 0, 0, 0, 0)
     55 #error "wrong value for __cpp_runtime_arrays"
     56 #endif
     57 
     58 #if check(aggregate_nsdmi, 0, 0, 201304, 201304)
     59 #error "wrong value for __cpp_aggregate_nsdmi"
     60 #endif
     61 
     62 #if check(variable_templates, 0, 0, 201304, 201304)
     63 #error "wrong value for __cpp_variable_templates"
     64 #endif
     65 
     66 #if check(unicode_characters, 0, 200704, 200704, 200704)
     67 #error "wrong value for __cpp_unicode_characters"
     68 #endif
     69 
     70 #if check(raw_strings, 0, 200710, 200710, 200710)
     71 #error "wrong value for __cpp_raw_strings"
     72 #endif
     73 
     74 #if check(unicode_literals, 0, 200710, 200710, 200710)
     75 #error "wrong value for __cpp_unicode_literals"
     76 #endif
     77 
     78 #if check(user_defined_literals, 0, 200809, 200809, 200809)
     79 #error "wrong value for __cpp_user_defined_literals"
     80 #endif
     81 
     82 #if check(lambdas, 0, 200907, 200907, 200907)
     83 #error "wrong value for __cpp_lambdas"
     84 #endif
     85 
     86 #if check(range_based_for, 0, 200907, 200907, 200907)
     87 #error "wrong value for __cpp_range_based_for"
     88 #endif
     89 
     90 #if check(static_assert, 0, 200410, 200410, 200410)
     91 #error "wrong value for __cpp_static_assert"
     92 #endif
     93 
     94 #if check(decltype, 0, 200707, 200707, 200707)
     95 #error "wrong value for __cpp_decltype"
     96 #endif
     97 
     98 #if check(attributes, 0, 200809, 200809, 200809)
     99 #error "wrong value for __cpp_attributes"
    100 #endif
    101 
    102 #if check(rvalue_references, 0, 200610, 200610, 200610)
    103 #error "wrong value for __cpp_rvalue_references"
    104 #endif
    105 
    106 #if check(variadic_templates, 0, 200704, 200704, 200704)
    107 #error "wrong value for __cpp_variadic_templates"
    108 #endif
    109 
    110 #if check(initializer_lists, 0, 200806, 200806, 200806)
    111 #error "wrong value for __cpp_initializer_lists"
    112 #endif
    113 
    114 #if check(delegating_constructors, 0, 200604, 200604, 200604)
    115 #error "wrong value for __cpp_delegating_constructors"
    116 #endif
    117 
    118 #if check(nsdmi, 0, 200809, 200809, 200809)
    119 #error "wrong value for __cpp_nsdmi"
    120 #endif
    121 
    122 #if check(inheriting_constructors, 0, 200802, 200802, 200802)
    123 #error "wrong value for __cpp_inheriting_constructors"
    124 #endif
    125 
    126 #if check(ref_qualifiers, 0, 200710, 200710, 200710)
    127 #error "wrong value for __cpp_ref_qualifiers"
    128 #endif
    129 
    130 #if check(alias_templates, 0, 200704, 200704, 200704)
    131 #error "wrong value for __cpp_alias_templates"
    132 #endif
    133 
    134 #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
    135 #error "wrong value for __cpp_experimental_concepts"
    136 #endif
    137 
    138 #if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines)
    139 #error "wrong value for __cpp_coroutines"
    140 #endif
    141