https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107571

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And looking at the C wording in n2596.pdf, seems it is different again:
"The next block item(6.8.2) that would be encountered after a fallthrough
declaration shall be a case label or default label associated with the smallest
enclosing switch statement."
So, if my understanding is well,
  int j = 0;
  switch (n)
    {
    case 1:
      for (int i = 0; i < 1; ++i)
        {
          [[fallthrough]]; // Invalid in both C and C++
        }
    case 2:
      while (++j < 2)
        {
          [[fallthrough]]; // Invalid in both C and C++
        }
    case 3:
      do
        {
          [[fallthrough]]; // Invalid in both C and C++
        }
      while (0);
    case 4:
      if (1)
        {
          [[fallthrough]]; // Invalid in C, valid in C++?
        }
    case 5:
      for (int i = 0; i < 1; ++i)
        [[fallthrough]]; // Invalid in C++, dunno about C
    case 6:
      while (++j < 2)
        [[fallthrough]]; // Invalid in C++, dunno about C
    case 7:
      do
        [[fallthrough]]; // Invalid in C++, dunno about C
      while (0);
    case 8:
      if (1)
        [[fallthrough]]; // Dunno about either C or C++
    case 9:
      {
        [[fallthrough]]; // Invalid in C, valid in C++?
      }
    default:
      break;
    }

Reply via email to