Thanks to visit codestin.com
Credit goes to github.com

Skip to content

diagnostics missing from -Wc++-compat #21898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zygoloid mannequin opened this issue Nov 11, 2014 · 2 comments · Fixed by #137234
Closed

diagnostics missing from -Wc++-compat #21898

zygoloid mannequin opened this issue Nov 11, 2014 · 2 comments · Fixed by #137234
Labels
bugzilla Issues migrated from bugzilla c c++ clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party

Comments

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Nov 11, 2014

Bugzilla Link 21524
Version trunk
OS Linux
CC @DougGregor

Extended Description

From http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/039875.html

clang doesn't print warning for following test-case:

compiled with: clang -fsyntax-only -Wc++-compat

int new;
struct A
{
struct B
{
int x;
}bs;
int y;
};
struct B b;

gcc -fsyntax-only -Wc++-compat prints following warnings (gcc-4.9.1 ubuntu):

t.c:1:5: warning: identifier ‘new’ conflicts with C++ keyword [-Wc++-compat]
int new;
^
t.c:13:8: warning: struct defined in struct or union is not visible in
C++ [-Wc++-compat]
struct B b;
^
t.c:5:10: note: struct defined here
struct B
^

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@wheatman wheatman added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party c labels Dec 7, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 7, 2023

@llvm/issue-subscribers-c

Author: None (ec04fc15-fa35-46f2-80e1-5d271f2ef708)

| | | | --- | --- | | Bugzilla Link | [21524](https://llvm.org/bz21524) | | Version | trunk | | OS | Linux | | CC | @DougGregor |

Extended Description

From http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/039875.html

clang doesn't print warning for following test-case:

compiled with: clang -fsyntax-only -Wc++-compat

int new;
struct A
{
struct B
{
int x;
}bs;
int y;
};
struct B b;

gcc -fsyntax-only -Wc++-compat prints following warnings (gcc-4.9.1 ubuntu):

t.c:1:5: warning: identifier ‘new’ conflicts with C++ keyword [-Wc++-compat]
int new;
^
t.c:13:8: warning: struct defined in struct or union is not visible in
C++ [-Wc++-compat]
struct B b;
^
t.c:5:10: note: struct defined here
struct B
^

@wheatman
Copy link
Contributor

wheatman commented Dec 7, 2023

This still exists in post 17 trunk(e68c265)

https://godbolt.org/z/fGcnGTrn5

code

int new;
struct A {
  struct B  { int x; } bs;
  int y;
};
struct B b;

clang gives no warnings with -Wc++-compat

on the other hand gcc gives the following warning

<source>:1:5: warning: identifier 'new' conflicts with C++ keyword [-Wc++-compat]
    1 | int new;
      |     ^~~
<source>:6:8: warning: struct defined in struct or union is not visible in C++ [-Wc++-compat]
    6 | struct B b;
      |        ^
<source>:3:10: note: struct defined here
    3 |   struct B  { int x; } bs;
      |          ^
Compiler returned: 0

AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Apr 24, 2025
This adds a new diagnostic group, -Widentifier-is-c++-keyword, which is
off by default and grouped under -Wc++-compat. The diagnostic catches
use of C++ keywords in C code.

This change additionally fixes an issue with -Wreserved-identifier not
diagnosing use of reserved identifiers in function parameter lists.

Partially fixes llvm#21898
AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Apr 25, 2025
This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped
under -Wc++-compat, that diagnoses declarations which are valid in C
but invalid in C++ due to the type being at the wrong scope. e.g.,

  struct S {
    struct T {
      int x;
    } t;
  };

  struct T t; // Valid C, invalid C++

This is implementing the other half of llvm#21898
AaronBallman added a commit that referenced this issue Apr 29, 2025
This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped
under -Wc++-compat, that diagnoses declarations which are valid in C but
invalid in C++ due to the type being at the wrong scope. e.g.,
```
  struct S {
    struct T {
      int x;
    } t;
  };

  struct T t; // Valid C, invalid C++
```
This is implementing the other half of #21898
AaronBallman added a commit that referenced this issue May 2, 2025
This adds a new diagnostic group, -Wc++-keyword, which is off by default
and grouped under -Wc++-compat. The diagnostic catches use of C++
keywords in C code.

This change additionally fixes an issue with -Wreserved-identifier not
diagnosing use of reserved identifiers in function parameter lists in a
function declaration which is not a definition.

Fixes #21898
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped
under -Wc++-compat, that diagnoses declarations which are valid in C but
invalid in C++ due to the type being at the wrong scope. e.g.,
```
  struct S {
    struct T {
      int x;
    } t;
  };

  struct T t; // Valid C, invalid C++
```
This is implementing the other half of llvm#21898
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This adds a new diagnostic group, -Wc++-keyword, which is off by default
and grouped under -Wc++-compat. The diagnostic catches use of C++
keywords in C code.

This change additionally fixes an issue with -Wreserved-identifier not
diagnosing use of reserved identifiers in function parameter lists in a
function declaration which is not a definition.

Fixes llvm#21898
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped
under -Wc++-compat, that diagnoses declarations which are valid in C but
invalid in C++ due to the type being at the wrong scope. e.g.,
```
  struct S {
    struct T {
      int x;
    } t;
  };

  struct T t; // Valid C, invalid C++
```
This is implementing the other half of llvm#21898
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This adds a new diagnostic group, -Wc++-keyword, which is off by default
and grouped under -Wc++-compat. The diagnostic catches use of C++
keywords in C code.

This change additionally fixes an issue with -Wreserved-identifier not
diagnosing use of reserved identifiers in function parameter lists in a
function declaration which is not a definition.

Fixes llvm#21898
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped
under -Wc++-compat, that diagnoses declarations which are valid in C but
invalid in C++ due to the type being at the wrong scope. e.g.,
```
  struct S {
    struct T {
      int x;
    } t;
  };

  struct T t; // Valid C, invalid C++
```
This is implementing the other half of llvm#21898
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This adds a new diagnostic group, -Wc++-keyword, which is off by default
and grouped under -Wc++-compat. The diagnostic catches use of C++
keywords in C code.

This change additionally fixes an issue with -Wreserved-identifier not
diagnosing use of reserved identifiers in function parameter lists in a
function declaration which is not a definition.

Fixes llvm#21898
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this issue May 6, 2025
This adds a new diagnostic group, -Wc++-keyword, which is off by default
and grouped under -Wc++-compat. The diagnostic catches use of C++
keywords in C code.

This change additionally fixes an issue with -Wreserved-identifier not
diagnosing use of reserved identifiers in function parameter lists in a
function declaration which is not a definition.

Fixes llvm/llvm-project#21898
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this issue May 7, 2025
This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped
under -Wc++-compat, that diagnoses declarations which are valid in C but
invalid in C++ due to the type being at the wrong scope. e.g.,
```
  struct S {
    struct T {
      int x;
    } t;
  };

  struct T t; // Valid C, invalid C++
```
This is implementing the other half of llvm#21898
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this issue May 7, 2025
This adds a new diagnostic group, -Wc++-keyword, which is off by default
and grouped under -Wc++-compat. The diagnostic catches use of C++
keywords in C code.

This change additionally fixes an issue with -Wreserved-identifier not
diagnosing use of reserved identifiers in function parameter lists in a
function declaration which is not a definition.

Fixes llvm#21898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c c++ clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants