i-c-e-cxx.cpp revision 0fb97083cc0f8a82e404e22991ae80d2216e71d5
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3// C++-specific tests for integral constant expressions. 4 5const int c = 10; 6int ar[c]; 7 8struct X0 { 9 static const int value = static_cast<int>(4.0); 10}; 11 12void f() { 13 if (const int value = 17) { 14 int array[value]; 15 } 16} 17 18int a() { 19 const int t=t; // expected-note {{subexpression not valid}} 20 switch(1) { // expected-warning {{no case matching constant switch condition '1'}} 21 case t:; // expected-error {{not an integer constant expression}} 22 } 23} 24 25// PR6206: out-of-line definitions are legit 26namespace pr6206 { 27 class Foo { 28 public: 29 static const int kBar; 30 }; 31 32 const int Foo::kBar = 20; 33 34 char Test() { 35 char str[Foo::kBar]; 36 str[0] = '0'; 37 return str[0]; 38 } 39} 40 41// PR6373: default arguments don't count. 42void pr6373(const unsigned x = 0) { 43 unsigned max = 80 / x; 44} 45