Skip to content

Commit f65b35d

Browse files
committed
[OpenACC] Stop trying to analyze invalid Var-Decls.
The code to analyze VarDecls for the purpose of ensuring a magic-static isn't present in a 'routine' was getting confused/crashed because we create something that looks like a magic-static during error-recovery, but it is still an invalid decl. This patch causes us to just 'give up' in the case where the vardecl is already invalid. Fixes: #140920
1 parent e12cbd8 commit f65b35d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ ExprResult SemaOpenACC::ActOnRoutineName(Expr *RoutineName) {
17561756
return ExprError();
17571757
}
17581758
void SemaOpenACC::ActOnVariableDeclarator(VarDecl *VD) {
1759-
if (!VD->isStaticLocal() || !getLangOpts().OpenACC)
1759+
if (!getLangOpts().OpenACC || VD->isInvalidDecl() || !VD->isStaticLocal())
17601760
return;
17611761

17621762
// This cast should be safe, since a static-local can only happen in a

clang/test/SemaOpenACC/gh140920.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 %s -fopenacc -verify
2+
3+
// Ensure that we are properly handling 'vardecl' when they are created during
4+
// error recovery. The errors themselves aren't really relevant/necessary to the
5+
// bug fix.
6+
struct Thing{ };
7+
struct pair {
8+
// expected-error@+2{{no member named 'T1'}}
9+
// expected-error@+1{{expected a qualified name after 'typename'}}
10+
template <typename enable_if<Thing::template T1<int>() &&
11+
!Thing::template T1<int>(),
12+
// expected-error@+4{{non-friend class member 'type' cannot have a qualified name}}
13+
// expected-error@+3{{type specifier is required}}
14+
// expected-error@+2{{non-static data member 'type' cannot be declared as a template}}
15+
// expected-error@+1{{no member named 'type' in the global namespace}}
16+
bool>::type = false>
17+
// expected-error@+1{{expected '(' for function-style cast or type construction}}
18+
void func(void);
19+
};

0 commit comments

Comments
 (0)