brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 6222b80 Raw
52 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -verify2 3void g(void) {4  if (1)5    [[clang::likely]] {}6}7void m(void) {8  [[clang::likely]] int x = 42; // expected-error {{'clang::likely' attribute cannot be applied to a declaration}}9 10  if (x)11    [[clang::unlikely]] {}12  if (x) {13    [[clang::unlikely]];14  }15  switch (x) {16  case 1:17    [[clang::likely]] {}18    break;19    [[clang::likely]] case 2 : case 3 : {}20    break;21  }22 23  do {24    [[clang::unlikely]];25  } while (x);26  do27    [[clang::unlikely]] {}28  while (x);29  do { // expected-note {{to match this 'do'}}30  }31  [[clang::unlikely]] while (x); // expected-error {{expected 'while' in do/while loop}}32  for (;;)33    [[clang::unlikely]] {}34  for (;;) {35    [[clang::unlikely]];36  }37  while (x)38    [[clang::unlikely]] {}39  while (x) {40    [[clang::unlikely]];41  }42 43  if (x)44    goto lbl;45 46  // FIXME: allow the attribute on the label47  [[clang::unlikely]] lbl : // expected-error {{'clang::unlikely' attribute cannot be applied to a declaration}}48  [[clang::likely]] x = x + 1;49 50  [[clang::likely]]++ x;51}52