diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index 290edc07fdc87..15c137098af35 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1278,13 +1278,16 @@ inline bool GetPtrThisBase(InterpState &S, CodePtr OpPC, uint32_t Off) { inline bool InitPtrPop(InterpState &S, CodePtr OpPC) { const Pointer &Ptr = S.Stk.pop(); - Ptr.initialize(); + if (Ptr.canBeInitialized()) + Ptr.initialize(); return true; } inline bool InitPtr(InterpState &S, CodePtr OpPC) { const Pointer &Ptr = S.Stk.peek(); - Ptr.initialize(); + + if (Ptr.canBeInitialized()) + Ptr.initialize(); return true; } diff --git a/clang/test/AST/Interp/complex.c b/clang/test/AST/Interp/complex.c new file mode 100644 index 0000000000000..b07d0241da12d --- /dev/null +++ b/clang/test/AST/Interp/complex.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both -Wno-unused-value %s +// RUN: %clang_cc1 -verify=ref,both -Wno-unused-value %s + +// expected-no-diagnostics +// ref-no-diagnostics + +void blah() { + __complex__ unsigned xx; + __complex__ signed yy; + __complex__ int result; + + /// The following line calls into the constant interpreter. + result = xx * yy; +}