brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 247c7ef Raw
30 lines · cpp
1// RUN: %clang_cc1 -verify=both,expected -std=c++11 -triple x86_64-linux -pedantic %s -fexperimental-new-constant-interpreter2// RUN: %clang_cc1 -verify=both,ref      -std=c++11 -triple x86_64-linux -pedantic %s3 4struct T { int n; };5const T t = { 42 }; // both-note 2{{declared here}}6struct S {7  int m : t.n; // both-warning {{width of bit-field 'm' (42 bits)}} \8               // both-warning {{expression is not an integral constant expression}} \9               // both-note {{read of non-constexpr variable 't' is not allowed}}10};11 12static_assert(t.n == 42, ""); // both-error {{expression is not an integral constant expression}} \13                              // both-note {{read of non-constexpr variable 't' is not allowed}}14 15namespace DynamicCast {16  struct S { int n; };17  constexpr S s { 16 };18  struct T {19    int n : dynamic_cast<const S*>(&s)->n; // both-warning {{constant expression}} \20                                           // both-note {{dynamic_cast}}21  };22}23 24namespace NewDelete {25  struct T {26    int n : *new int(4); // both-warning {{constant expression}} \27                         // both-note {{until C++20}}28  };29}30