Skip to content
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

diagnostics missing from -Wc++-compat #21898

Open
zygoloid mannequin opened this issue Nov 11, 2014 · 2 comments
Open

diagnostics missing from -Wc++-compat #21898

zygoloid mannequin opened this issue Nov 11, 2014 · 2 comments
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
Collaborator

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

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

No branches or pull requests

2 participants