brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 58d7f36 Raw
49 lines · cpp
1// RUN: %clang_cc1 -std=c++03 -verify=expected,both %s -fexperimental-new-constant-interpreter2// RUN: %clang_cc1 -std=c++03 -verify=ref,both %s3 4namespace NonInitializingMemberExpr {5  struct NonLit {6    NonLit() : value(0) {}7    int value;8  };9  __attribute__((require_constant_initialization)) const int &nl_subobj_ref = NonLit().value; // both-error {{variable does not have a constant initializer}} \10                                                                                              // both-note {{required by}} \11                                                                                              // both-note {{subexpression not valid}}12}13 14 15namespace NonLValueMemberExpr {16  struct PODType {17    int value;18  };19 20#define ATTR __attribute__((require_constant_initialization))21  struct TT1 {22    ATTR static const int &subobj_init;23  };24 25  const int &TT1::subobj_init = PODType().value;26}27 28void LambdaAccessingADummy() {29  int d;30  int a9[1] = {[d = 0] = 1}; // both-error {{is not an integral constant expression}}31}32 33const int p = 10;34struct B {35  int a;36  void *p;37};38struct B2 : B {39  void *q;40};41_Static_assert(&(B2().a) == &p, ""); // both-error {{taking the address of a temporary object of type 'int'}} \42                                     // both-error {{not an integral constant expression}}43 44typedef __attribute__((ext_vector_type(4))) int vi4b;45struct S {46  vi4b w;47};48const int s = S().w[1];49