Skip to content

_Alignas on a struct declaration gives a low-quality diagnostic #58637

Closed
@AaronBallman

Description

@AaronBallman
_Alignas(int) struct T {
  int i;
};

gives the diagnostic: warning: attribute '_Alignas' is ignored, place it after "struct" to apply attribute to type declaration which seems like a really helpful message at first glance. However, C does not allow you to put an _Alignas specifier on the struct type itself. So following that advice:

struct _Alignas(int) T {
  int i;
};

gives: error: declaration of anonymous struct must be a definition and warning: declaration does not declare anything.

The original diagnostic should say the attribute is ignored without the helpful message about placement (which is correct for C++).

Metadata

Metadata

Assignees

Labels

c11clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing featuregood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions