<commit_before>// RUN: clang -fsyntax-only -verify %s

// See if aliasing can confuse this baby.
typedef char c;
typedef c *cp;
typedef cp *cpp;
typedef cpp *cppp;
typedef cppp &cpppr;
typedef const cppp &cpppcr;
typedef const char cc;
typedef cc *ccp;
typedef volatile ccp ccvp;
typedef ccvp *ccvpp;
typedef const volatile ccvpp ccvpcvp;
typedef ccvpcvp *ccvpcvpp;
typedef int iar[100];
typedef iar &iarr;
typedef int (*f)(int);

char ***good_const_cast_test(ccvpcvpp var)
{
  // Cast away deep consts and volatiles.
  char ***var2 = const_cast<cppp>(var);
  char ***const &var3 = static_cast<cpppcr>(var2); // Different bug.
  // Const reference to reference.
  char ***&var4 = const_cast<cpppr>(var3);
  // Drop reference. Intentionally without qualifier change.
  char *** var5 = const_cast<cppp>(var4);
  const int ar[100] = {0};
  int (&rar)[100] = const_cast<iarr>(ar); // expected-warning {{statement was disambiguated as declaration}} expected-error {{const_cast from 'int const [100]' to 'iarr' is not allowed}}
  // Array decay. Intentionally without qualifier change.
  int *pi = const_cast<int*>(ar);
  f fp = 0;
  // Don't misidentify fn** as a function pointer.
  f *fpp = const_cast<f*>(&fp);
  return var4;
}

short *bad_const_cast_test(char const *volatile *const volatile *var)
{
  // Different pointer levels.
  char **var2 = const_cast<char**>(var); // expected-error {{const_cast from 'char const *volatile *const volatile *' to 'char **' is not allowed}}<commit_msg>Remove workaround for reference. No longer necessary.<commit_after>// RUN: clang -fsyntax-only -verify %s

// See if aliasing can confuse this baby.
typedef char c;
typedef c *cp;
typedef cp *cpp;
typedef cpp *cppp;
typedef cppp &cpppr;
typedef const cppp &cpppcr;
typedef const char cc;
typedef cc *ccp;
typedef volatile ccp ccvp;
typedef ccvp *ccvpp;
typedef const volatile ccvpp ccvpcvp;
typedef ccvpcvp *ccvpcvpp;
typedef int iar[100];
typedef iar &iarr;
typedef int (*f)(int);

char ***good_const_cast_test(ccvpcvpp var)
{
  // Cast away deep consts and volatiles.
  char ***var2 = const_cast<cppp>(var);
  char ***const &var3 = var2;
  // Const reference to reference.
  char ***&var4 = const_cast<cpppr>(var3);
  // Drop reference. Intentionally without qualifier change.
  char *** var5 = const_cast<cppp>(var4);
  const int ar[100] = {0};
  int (&rar)[100] = const_cast<iarr>(ar); // expected-warning {{statement was disambiguated as declaration}} expected-error {{const_cast from 'int const [100]' to 'iarr' is not allowed}}
  // Array decay. Intentionally without qualifier change.
  int *pi = const_cast<int*>(ar);
  f fp = 0;
  // Don't misidentify fn** as a function pointer.
  f *fpp = const_cast<f*>(&fp);
  return var4;
}

short *bad_const_cast_test(char const *volatile *const volatile *var)
{
  // Different pointer levels.
  char **var2 = const_cast<char**>(var); // expected-error {{const_cast from 'char const *volatile *const volatile *' to 'char **' is not allowed}}
{'fraction_non_alphanumeric': 0.1346089291708627, 'fraction_numerical': 0.01544142329640819, 'mean_word_length': 4.467889908256881, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7220230', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1009, 'n_words': 345}