[all-commits] [llvm/llvm-project] e16882: fix bug that undefined internal is a warning only ...

Constantin Kronbichler via All-commits all-commits at lists.llvm.org
Thu Jul 11 09:36:10 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e16882fc7416a30d56d5b5a19d549ca7c653e668
      https://github.com/llvm/llvm-project/commit/e16882fc7416a30d56d5b5a19d549ca7c653e668
  Author: Constantin Kronbichler <56307024+ccrownhill at users.noreply.github.com>
  Date:   2024-07-11 (Thu, 11 Jul 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    A clang/test/Sema/undefined-internal-basic.c
    A clang/test/Sema/undefined-internal-typeof-c23.c

  Log Message:
  -----------
  fix bug that undefined internal is a warning only for -pedantic-errors (#98016)

This fixes issue #39558 which mentions the problem when compiling the
following code with `-pedantic-errors` flag (it also mentions `-Wall
-Wextra` but those shouldn't change the output, which is also the case
in GCC):

```c
static void f();

int main()
{
    f;
}
```

Clang only outputs an `undefined-internal` warning on the first line,
but according to 6.9/3

```
"... Moreover, if an identifier declared with internal linkage is used in an
 expression (other than as a part of the operand of a sizeof or _Alignof
 operator whose result is an integer constant), there shall be exactly one
 external definition for the identifier in the translation unit."
```

this should be illegal and hence an error.

I fixed this by changing the warning type from `Warning` to `ExtWarn`
and by adding a suitable test.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list