Skip to content

Commit e0a33cb

Browse files
camcshafik
andauthored
[clang] Allow attributes on first constructor argument in pre-C++11 (#157300)
Resolves GH-156809 Modifies decl parser to allow C++11 style [[attributes]] on the first argument in constructors in all C++ standards. They are already allowed on later arguments. --------- Co-authored-by: Shafik Yaghmour <[email protected]>
1 parent d0263f0 commit e0a33cb

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ Bug Fixes to C++ Support
365365
authentication enabled. (#GH152601)
366366
- Fix the check for narrowing int-to-float conversions, so that they are detected in
367367
cases where converting the float back to an integer is undefined behaviour (#GH157067).
368+
- Stop rejecting C++11-style attributes on the first argument of constructors in older
369+
standards. (#GH156809).
368370
- Fix a crash when applying binary or ternary operators to two same function types with different spellings,
369371
where at least one of the function parameters has an attribute which affects
370372
the function type.

clang/lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6007,10 +6007,9 @@ bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide,
60076007

60086008
// A C++11 attribute here signals that we have a constructor, and is an
60096009
// attribute on the first constructor parameter.
6010-
if (getLangOpts().CPlusPlus11 &&
6011-
isCXX11AttributeSpecifier(/*Disambiguate*/ false,
6012-
/*OuterMightBeMessageSend*/ true) !=
6013-
CXX11AttributeKind::NotAttributeSpecifier) {
6010+
if (isCXX11AttributeSpecifier(/*Disambiguate=*/false,
6011+
/*OuterMightBeMessageSend=*/true) !=
6012+
CXX11AttributeKind::NotAttributeSpecifier) {
60146013
return true;
60156014
}
60166015

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++03 %s
2+
// expected-no-diagnostics
3+
4+
struct S {
5+
S([[clang::lifetimebound]] int&) {}
6+
};

0 commit comments

Comments
 (0)