File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -2459,6 +2459,17 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
2459
2459
return this ->emitGetPtrThisField (Offset, E);
2460
2460
}
2461
2461
2462
+ // Lazily visit global declarations we haven't seen yet.
2463
+ // This happens in C.
2464
+ if (!Ctx.getLangOpts ().CPlusPlus ) {
2465
+ if (const auto *VD = dyn_cast<VarDecl>(D);
2466
+ VD && VD->hasGlobalStorage () && VD->getAnyInitializer ()) {
2467
+ if (!this ->visitVarDecl (VD))
2468
+ return false ;
2469
+ // Retry.
2470
+ return this ->VisitDeclRefExpr (E);
2471
+ }
2472
+ }
2462
2473
return false ;
2463
2474
}
2464
2475
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
2
+ // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -pedantic -verify=pedantic-expected %s
2
3
// RUN: %clang_cc1 -verify=ref %s
4
+ // RUN: %clang_cc1 -pedantic -verify=pedantic-ref %s
3
5
4
6
/// expected-no-diagnostics
5
- /// ref-no-diagnostics
6
7
7
8
_Static_assert (1 , "" );
8
9
_Static_assert (0 != 1 , "" );
9
- _Static_assert (1.0 == 1.0 , "" );
10
+ _Static_assert (1.0 == 1.0 , "" ); // pedantic-ref-warning {{not an integer constant expression}} \
11
+ // pedantic-expected-warning {{not an integer constant expression}}
10
12
_Static_assert ( (5 > 4 ) + (3 > 2 ) == 2 , "" );
11
13
14
+ /// FIXME: Should also be rejected in the new interpreter
12
15
int a = (1 == 1 ? 5 : 3 );
16
+ _Static_assert (a == 5 , "" ); // ref-error {{not an integral constant expression}} \
17
+ // pedantic-ref-error {{not an integral constant expression}} \
18
+ // pedantic-expected-warning {{not an integer constant expression}}
19
+
20
+ const int b = 3 ;
21
+ _Static_assert (b == 3 , "" ); // pedantic-ref-warning {{not an integer constant expression}} \
22
+ // pedantic-expected-warning {{not an integer constant expression}}
23
+
You can’t perform that action at this time.
0 commit comments