Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ Non-comprehensive list of changes in this release
allocation functions with a token ID can be enabled via the
``-fsanitize=alloc-token`` flag.

- Clang now rejects the invalid use of ``constexpr`` with ``auto`` and an explicit type. (#GH163090)

New Compiler Flags
------------------
- New option ``-fno-sanitize-debug-trap-reasons`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``).
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/DeclSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {

if (S.getLangOpts().C23 &&
getConstexprSpecifier() == ConstexprSpecKind::Constexpr &&
StorageClassSpec == SCS_extern) {
(StorageClassSpec == SCS_extern || StorageClassSpec == SCS_auto)) {
S.Diag(ConstexprLoc, diag::err_invalid_decl_spec_combination)
<< DeclSpec::getSpecifierName(getStorageClassSpec())
<< SourceRange(getStorageClassSpecLoc());
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Parser/c2x-auto.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ auto basic_usage(auto auto) { // c23-error {{'auto' not allowed in function pr

int auto_cxx_decl = auto(0); // expected-error {{expected expression}}

constexpr auto int x = 0; // c23-error {{cannot combine with previous 'auto' declaration specifier}} \
c17-error {{use of undeclared identifier 'constexpr'}}
return c;
}

Expand Down