blob: 5e28e7f0ce5f38c463a7bc942c3f20547224031e [file] [log] [blame]
Richard Smith40b993a2012-01-18 03:06:12 +00001// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -pedantic
2
3# 1 "/usr/include/string.h" 1 3 4
4extern "C" {
5 typedef decltype(sizeof(int)) size_t;
6 extern size_t strlen(const char *p);
7}
8
9# 10 "SemaCXX/constexpr-strlen.cpp" 2
10constexpr int n = __builtin_strlen("hello"); // ok
11constexpr int m = strlen("hello"); // expected-error {{constant expression}} expected-note {{non-constexpr function 'strlen' cannot be used in a constant expression}}
12
13// Make sure we can evaluate a call to strlen.
14int arr[3]; // expected-note {{here}}
15int k = arr[strlen("hello")]; // expected-warning {{array index 5}}