Skip to content

Commit 7719244

Browse files
committed
Merge commit '73e22ff3d77db72bb9b6e22342417a5f4fe6afb4' into llvmspirv_pulldown
2 parents bc81973 + 73e22ff commit 7719244

File tree

180 files changed

+25745
-965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+25745
-965
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ Improvements to Clang's diagnostics
541541
- Clang emits a ``-Wparentheses`` warning for expressions with consecutive comparisons like ``x < y < z``.
542542
Fixes #GH20456.
543543

544+
- Clang no longer emits a "declared here" note for a builtin function that has no declaration in source.
545+
Fixes #GH93369.
546+
544547
Improvements to Clang's time-trace
545548
----------------------------------
546549

@@ -802,6 +805,8 @@ Bug Fixes to C++ Support
802805
- Fixed a regression introduced in Clang 18 causing a static function overloading a non-static function
803806
with the same parameters not to be diagnosed. (Fixes #GH93456).
804807
- Clang now diagnoses unexpanded parameter packs in attributes. (Fixes #GH93269).
808+
- Clang now allows ``@$``` in raw string literals. Fixes (#GH93130).
809+
- Fix an assertion failure when checking invalid ``this`` usage in the wrong context. (Fixes #GH91536).
805810

806811
Bug Fixes to AST Handling
807812
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/Attr.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,9 +2973,12 @@ def Convergent : InheritableAttr {
29732973
def NoInline : DeclOrStmtAttr {
29742974
let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
29752975
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
2976+
CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
29762977
Declspec<"noinline">];
2977-
let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
2978-
C23<"clang", "noinline">]>];
2978+
let Accessors = [Accessor<"isStmtNoInline", [CXX11<"clang", "noinline">,
2979+
C23<"clang", "noinline">,
2980+
CXX11<"msvc", "noinline">,
2981+
C23<"msvc", "noinline">]>];
29792982
let Documentation = [NoInlineDocs];
29802983
let Subjects = SubjectList<[Function, Stmt], WarnDiag,
29812984
"functions and statements">;

clang/include/clang/Basic/CharInfo.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ namespace charinfo {
2828
CHAR_LOWER = 0x0040, // a-z
2929
CHAR_UNDER = 0x0080, // _
3030
CHAR_PERIOD = 0x0100, // .
31-
CHAR_RAWDEL = 0x0200, // {}[]#<>%:;?*+-/^&|~!=,"'
32-
CHAR_PUNCT = 0x0400 // `$@()
31+
CHAR_PUNCT = 0x0200, // {}[]#<>%:;?*+-/^&|~!=,"'`$@()
3332
};
3433

3534
enum {
@@ -152,16 +151,17 @@ LLVM_READONLY inline bool isHexDigit(unsigned char c) {
152151
/// Note that '_' is both a punctuation character and an identifier character!
153152
LLVM_READONLY inline bool isPunctuation(unsigned char c) {
154153
using namespace charinfo;
155-
return (InfoTable[c] & (CHAR_UNDER|CHAR_PERIOD|CHAR_RAWDEL|CHAR_PUNCT)) != 0;
154+
return (InfoTable[c] &
155+
(CHAR_UNDER | CHAR_PERIOD | CHAR_PUNCT | CHAR_PUNCT)) != 0;
156156
}
157157

158158
/// Return true if this character is an ASCII printable character; that is, a
159159
/// character that should take exactly one column to print in a fixed-width
160160
/// terminal.
161161
LLVM_READONLY inline bool isPrintable(unsigned char c) {
162162
using namespace charinfo;
163-
return (InfoTable[c] & (CHAR_UPPER|CHAR_LOWER|CHAR_PERIOD|CHAR_PUNCT|
164-
CHAR_DIGIT|CHAR_UNDER|CHAR_RAWDEL|CHAR_SPACE)) != 0;
163+
return (InfoTable[c] & (CHAR_UPPER | CHAR_LOWER | CHAR_PERIOD | CHAR_PUNCT |
164+
CHAR_DIGIT | CHAR_UNDER | CHAR_SPACE)) != 0;
165165
}
166166

167167
/// Return true if this is the body character of a C preprocessing number,
@@ -175,8 +175,9 @@ LLVM_READONLY inline bool isPreprocessingNumberBody(unsigned char c) {
175175
/// Return true if this is the body character of a C++ raw string delimiter.
176176
LLVM_READONLY inline bool isRawStringDelimBody(unsigned char c) {
177177
using namespace charinfo;
178-
return (InfoTable[c] & (CHAR_UPPER|CHAR_LOWER|CHAR_PERIOD|
179-
CHAR_DIGIT|CHAR_UNDER|CHAR_RAWDEL)) != 0;
178+
return (InfoTable[c] & (CHAR_UPPER | CHAR_LOWER | CHAR_PERIOD | CHAR_DIGIT |
179+
CHAR_UNDER | CHAR_PUNCT)) != 0 &&
180+
c != '(' && c != ')';
180181
}
181182

182183
enum class EscapeChar {

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ def warn_cxx98_compat_raw_string_literal : Warning<
111111
"raw string literals are incompatible with C++98">,
112112
InGroup<CXX98Compat>, DefaultIgnore;
113113

114+
def warn_cxx26_compat_raw_string_literal_character_set : Warning<
115+
" '%0' in a raw string literal delimiter is incompatible "
116+
"with standards before C++2c">,
117+
InGroup<CXXPre26Compat>, DefaultIgnore;
118+
def ext_cxx26_raw_string_literal_character_set : Extension<
119+
" '%0' in a raw string literal delimiter is a C++2c extension">,
120+
InGroup<CXX26>, DefaultIgnore;
121+
114122
def warn_multichar_character_literal : Warning<
115123
"multi-character character constant">, InGroup<MultiChar>;
116124
def warn_four_char_character_literal : Warning<

clang/lib/AST/APValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ QualType APValue::LValueBase::getType() const {
9090
// For a materialized temporary, the type of the temporary we materialized
9191
// may not be the type of the expression.
9292
if (const MaterializeTemporaryExpr *MTE =
93-
clang::dyn_cast<MaterializeTemporaryExpr>(Base)) {
93+
llvm::dyn_cast<MaterializeTemporaryExpr>(Base)) {
9494
SmallVector<const Expr *, 2> CommaLHSs;
9595
SmallVector<SubobjectAdjustment, 2> Adjustments;
9696
const Expr *Temp = MTE->getSubExpr();

clang/lib/Analysis/MacroExpansionContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define DEBUG_TYPE "macro-expansion-context"
1414

15-
static void dumpTokenInto(const clang::Preprocessor &PP, clang::raw_ostream &OS,
15+
static void dumpTokenInto(const clang::Preprocessor &PP, llvm::raw_ostream &OS,
1616
clang::Token Tok);
1717

1818
namespace clang {

clang/lib/Basic/CharInfo.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ const uint16_t clang::charinfo::InfoTable[256] = {
3131
0 , 0 , 0 , 0 ,
3232
//32 SP 33 ! 34 " 35 #
3333
//36 $ 37 % 38 & 39 '
34-
CHAR_SPACE , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
35-
CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
34+
CHAR_SPACE , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
35+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
3636
//40 ( 41 ) 42 * 43 +
3737
//44 , 45 - 46 . 47 /
38-
CHAR_PUNCT , CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL ,
39-
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_PERIOD , CHAR_RAWDEL ,
38+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
39+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PERIOD , CHAR_PUNCT ,
4040
//48 0 49 1 50 2 51 3
4141
//52 4 53 5 54 6 55 7
4242
CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT ,
4343
CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT ,
4444
//56 8 57 9 58 : 59 ;
4545
//60 < 61 = 62 > 63 ?
46-
CHAR_DIGIT , CHAR_DIGIT , CHAR_RAWDEL , CHAR_RAWDEL ,
47-
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
46+
CHAR_DIGIT , CHAR_DIGIT , CHAR_PUNCT , CHAR_PUNCT ,
47+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
4848
//64 @ 65 A 66 B 67 C
4949
//68 D 69 E 70 F 71 G
5050
CHAR_PUNCT , CHAR_XUPPER , CHAR_XUPPER , CHAR_XUPPER ,
@@ -59,8 +59,8 @@ const uint16_t clang::charinfo::InfoTable[256] = {
5959
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_UPPER ,
6060
//88 X 89 Y 90 Z 91 [
6161
//92 \ 93 ] 94 ^ 95 _
62-
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_RAWDEL ,
63-
CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_UNDER ,
62+
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_PUNCT ,
63+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_UNDER ,
6464
//96 ` 97 a 98 b 99 c
6565
//100 d 101 e 102 f 103 g
6666
CHAR_PUNCT , CHAR_XLOWER , CHAR_XLOWER , CHAR_XLOWER ,
@@ -75,6 +75,6 @@ const uint16_t clang::charinfo::InfoTable[256] = {
7575
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_LOWER ,
7676
//120 x 121 y 122 z 123 {
7777
//124 | 125 } 126 ~ 127 DEL
78-
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_RAWDEL ,
79-
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL , 0
78+
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_PUNCT ,
79+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , 0
8080
};

clang/lib/Lex/Lexer.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,8 +2261,17 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr,
22612261

22622262
unsigned PrefixLen = 0;
22632263

2264-
while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen]))
2264+
while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) {
22652265
++PrefixLen;
2266+
if (!isLexingRawMode() &&
2267+
llvm::is_contained({'$', '@', '`'}, CurPtr[PrefixLen])) {
2268+
const char *Pos = &CurPtr[PrefixLen];
2269+
Diag(Pos, LangOpts.CPlusPlus26
2270+
? diag::warn_cxx26_compat_raw_string_literal_character_set
2271+
: diag::ext_cxx26_raw_string_literal_character_set)
2272+
<< StringRef(Pos, 1);
2273+
}
2274+
}
22662275

22672276
// If the last character was not a '(', then we didn't lex a valid delimiter.
22682277
if (CurPtr[PrefixLen] != '(') {

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,10 +1449,10 @@ bool Sema::CheckCXXThisType(SourceLocation Loc, QualType Type) {
14491449
// category are defined within such member functions as they are within
14501450
// an implicit object member function).
14511451
DeclContext *DC = getFunctionLevelDeclContext();
1452-
if (const auto *Method = dyn_cast<CXXMethodDecl>(DC);
1453-
Method && Method->isExplicitObjectMemberFunction()) {
1452+
const auto *Method = dyn_cast<CXXMethodDecl>(DC);
1453+
if (Method && Method->isExplicitObjectMemberFunction()) {
14541454
Diag(Loc, diag::err_invalid_this_use) << 1;
1455-
} else if (isLambdaCallWithExplicitObjectParameter(CurContext)) {
1455+
} else if (Method && isLambdaCallWithExplicitObjectParameter(CurContext)) {
14561456
Diag(Loc, diag::err_invalid_this_use) << 1;
14571457
} else {
14581458
Diag(Loc, diag::err_invalid_this_use) << 0;

clang/lib/Sema/SemaLookup.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5948,6 +5948,16 @@ void Sema::diagnoseTypo(const TypoCorrection &Correction,
59485948

59495949
NamedDecl *ChosenDecl =
59505950
Correction.isKeyword() ? nullptr : Correction.getFoundDecl();
5951+
5952+
// For builtin functions which aren't declared anywhere in source,
5953+
// don't emit the "declared here" note.
5954+
if (const auto *FD = dyn_cast_if_present<FunctionDecl>(ChosenDecl);
5955+
FD && FD->getBuiltinID() &&
5956+
PrevNote.getDiagID() == diag::note_previous_decl &&
5957+
Correction.getCorrectionRange().getBegin() == FD->getBeginLoc()) {
5958+
ChosenDecl = nullptr;
5959+
}
5960+
59515961
if (PrevNote.getDiagID() && ChosenDecl)
59525962
Diag(ChosenDecl->getLocation(), PrevNote)
59535963
<< CorrectedQuotedStr << (ErrorRecovery ? FixItHint() : FixTypo);

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ bool Sema::CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
700700
static Attr *handleNoInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A,
701701
SourceRange Range) {
702702
NoInlineAttr NIA(S.Context, A);
703-
if (!NIA.isClangNoInline()) {
703+
if (!NIA.isStmtNoInline()) {
704704
S.Diag(St->getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
705705
<< "[[clang::noinline]]";
706706
return nullptr;
@@ -1263,10 +1263,8 @@ ExprResult Sema::ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A,
12631263
}
12641264

12651265
if (!getLangOpts().CPlusPlus23 &&
1266-
A.getSyntax() == AttributeCommonInfo::AS_CXX11) {
1267-
llvm::dbgs() << "Syntax: " << int(A.getSyntax()) << "\n";
1266+
A.getSyntax() == AttributeCommonInfo::AS_CXX11)
12681267
Diag(A.getLoc(), diag::ext_cxx23_attr) << A << Range;
1269-
}
12701268

12711269
return Assumption;
12721270
}

clang/test/CodeGen/attr-noinline.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static int baz(int x) {
99
}
1010

1111
[[clang::noinline]] bool noi() { }
12+
[[msvc::noinline]] bool ms_noi() { return true; }
1213

1314
void foo(int i) {
1415
[[clang::noinline]] bar();
@@ -39,6 +40,31 @@ void foo(int i) {
3940
// CHECK: call noundef zeroext i1 @_Z3barv()
4041
}
4142

43+
void ms_noi_check(int i) {
44+
[[msvc::noinline]] bar();
45+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
46+
[[msvc::noinline]] i = baz(i);
47+
// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
48+
[[msvc::noinline]] (i = 4, bar());
49+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
50+
[[msvc::noinline]] (void)(bar());
51+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
52+
[[msvc::noinline]] f(bar(), bar());
53+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
54+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
55+
// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
56+
[[msvc::noinline]] [] { bar(); bar(); }(); // noinline only applies to the anonymous function call
57+
// CHECK: call void @"_ZZ12ms_noi_checkiENK3$_0clEv"(ptr {{[^,]*}} %ref.tmp) #[[NOINLINEATTR]]
58+
[[msvc::noinline]] for (bar(); bar(); bar()) {}
59+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
60+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
61+
// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
62+
[[msvc::noinline]] ms_noi();
63+
// CHECK: call noundef zeroext i1 @_Z6ms_noiv()
64+
ms_noi();
65+
// CHECK: call noundef zeroext i1 @_Z6ms_noiv()
66+
}
67+
4268
struct S {
4369
friend bool operator==(const S &LHS, const S &RHS);
4470
};
@@ -50,6 +76,12 @@ void func(const S &s1, const S &s2) {
5076
bool b;
5177
[[clang::noinline]] b = s1 == s2;
5278
// CHECK: call noundef zeroext i1 @_ZeqRK1SS1_({{.*}}) #[[NOINLINEATTR]]
79+
80+
[[msvc::noinline]]g(s1 == s2);
81+
// CHECK: call noundef zeroext i1 @_ZeqRK1SS1_({{.*}}) #[[NOINLINEATTR]]
82+
// CHECK: call void @_Z1gb({{.*}}) #[[NOINLINEATTR]]
83+
[[msvc::noinline]] b = s1 == s2;
84+
// CHECK: call noundef zeroext i1 @_ZeqRK1SS1_({{.*}}) #[[NOINLINEATTR]]
5385
}
5486

5587
// CHECK: attributes #[[NOINLINEATTR]] = { noinline }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wc++26-extensions %s
2+
// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify=cxx26 -Wpre-c++26-compat %s
3+
4+
int main() {
5+
(void) R"abc`@$(foobar)abc`@$";
6+
//expected-warning@-1 {{'`' in a raw string literal delimiter is a C++2c extension}}
7+
//expected-warning@-2 {{'@' in a raw string literal delimiter is a C++2c extension}}
8+
//expected-warning@-3 {{'$' in a raw string literal delimiter is a C++2c extension}}
9+
//cxx26-warning@-4 {{'`' in a raw string literal delimiter is incompatible with standards before C++2c}}
10+
//cxx26-warning@-5 {{'@' in a raw string literal delimiter is incompatible with standards before C++2c}}
11+
//cxx26-warning@-6 {{'$' in a raw string literal delimiter is incompatible with standards before C++2c}}
12+
}

clang/test/Sema/attr-noinline.cpp

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
int bar();
44

5-
// expected-note@+1{{conflicting attribute is here}}
5+
// expected-note@+1 2 {{conflicting attribute is here}}
66
[[gnu::always_inline]] void always_inline_fn(void) { }
7-
// expected-note@+1{{conflicting attribute is here}}
7+
// expected-note@+1 2 {{conflicting attribute is here}}
88
[[gnu::flatten]] void flatten_fn(void) { }
99
[[gnu::noinline]] void noinline_fn(void) { }
1010

@@ -25,7 +25,21 @@ void foo() {
2525
__attribute__((noinline)) bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::noinline]]' on statements}}
2626
}
2727

28+
void ms_noi_check() {
29+
[[msvc::noinline]] bar();
30+
[[msvc::noinline(0)]] bar(); // expected-error {{'noinline' attribute takes no arguments}}
31+
int x;
32+
[[msvc::noinline]] x = 0; // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
33+
[[msvc::noinline]] { asm("nop"); } // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
34+
[[msvc::noinline]] label: x = 1; // expected-warning {{'noinline' attribute only applies to functions and statements}}
35+
36+
[[msvc::noinline]] always_inline_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
37+
[[msvc::noinline]] flatten_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'flatten'}}
38+
[[msvc::noinline]] noinline_fn();
39+
}
40+
2841
[[clang::noinline]] static int i = bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}
42+
[[msvc::noinline]] static int j = bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}
2943

3044
// This used to crash the compiler.
3145
template<int D>
@@ -69,7 +83,39 @@ int variadic_baz(int x) {
6983
[[clang::noinline]] return non_dependent(x) + (dependent<D>(x) + ...);
7084
}
7185

86+
template<int D> [[clang::always_inline]]
87+
int qux(int x) { // #QUX
88+
// expected-warning@+2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
89+
// expected-note@#NO_DEP{{conflicting attribute is here}}
90+
[[msvc::noinline]] non_dependent(x);
91+
if constexpr (D>0) {
92+
// expected-warning@+6{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
93+
// expected-note@#NO_DEP{{conflicting attribute is here}}
94+
// expected-warning@+4 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
95+
// expected-note@#QUX 3{{conflicting attribute is here}}
96+
// expected-note@#QUX_INST 3{{in instantiation}}
97+
// expected-note@+1 3{{in instantiation}}
98+
[[msvc::noinline]] return non_dependent(x), qux<D-1>(x + 1);
99+
}
100+
return x;
101+
}
102+
103+
// We can't suppress if there is a variadic involved.
104+
template<int ... D>
105+
int variadic_qux(int x) {
106+
// Diagnoses NO_DEP 2x, once during phase 1, the second during instantiation.
107+
// Dianoses DEP 3x, once per variadic expansion.
108+
// expected-warning@+5 2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
109+
// expected-note@#NO_DEP 2{{conflicting attribute is here}}
110+
// expected-warning@+3 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
111+
// expected-note@#DEP 3{{conflicting attribute is here}}
112+
// expected-note@#QUX_VARIADIC_INST{{in instantiation}}
113+
[[msvc::noinline]] return non_dependent(x) + (dependent<D>(x) + ...);
114+
}
115+
72116
void use() {
73117
baz<3>(0); // #BAZ_INST
74118
variadic_baz<0, 1, 2>(0); // #VARIADIC_INST
119+
qux<3>(0); // #QUX_INST
120+
variadic_qux<0, 1, 2>(0); // #QUX_VARIADIC_INST
75121
}

clang/test/SemaCXX/invalid-if-constexpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ namespace GH61885 {
44
void similar() { // expected-note {{'similar' declared here}}
55
if constexpr (similer<>) {} // expected-error {{use of undeclared identifier 'similer'; did you mean 'similar'?}}
66
}
7-
void a() { if constexpr (__adl_swap<>) {}} // expected-error{{use of undeclared identifier '__adl_swap'; did you mean '__sync_swap'?}} \
8-
// expected-note {{'__sync_swap' declared here}}
7+
void a() { if constexpr (__adl_swap<>) {}} // expected-error{{use of undeclared identifier '__adl_swap'; did you mean '__sync_swap'?}}
98

109
int AA() { return true;} // expected-note {{'AA' declared here}}
1110

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2+
3+
decltype([]()->decltype(this) { }) a; // expected-error {{invalid use of 'this' outside of a non-static member function}}
4+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
3+
// Test that clang does not emit 'declared here' note for builtin functions that don't have a declaration in source.
4+
5+
void t0() {
6+
constexpr float A = __builtin_isinfinity(); // expected-error {{use of undeclared identifier '__builtin_isinfinity'; did you mean '__builtin_isfinite'?}}
7+
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
8+
}

0 commit comments

Comments
 (0)