140b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -pedantic
240b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith
340b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith# 1 "/usr/include/string.h" 1 3 4
440b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smithextern "C" {
540b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith  typedef decltype(sizeof(int)) size_t;
640b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith  extern size_t strlen(const char *p);
740b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith}
840b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith
940b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith# 10 "SemaCXX/constexpr-strlen.cpp" 2
1040b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smithconstexpr int n = __builtin_strlen("hello"); // ok
1140b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smithconstexpr int m = strlen("hello"); // expected-error {{constant expression}} expected-note {{non-constexpr function 'strlen' cannot be used in a constant expression}}
1240b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith
1340b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smith// Make sure we can evaluate a call to strlen.
1440b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smithint arr[3]; // expected-note {{here}}
1540b993a826728214c869ee4fbc9d296a2e1e1f71Richard Smithint k = arr[strlen("hello")]; // expected-warning {{array index 5}}
16