Fixed bug in C++ to prevent parsing 'private' as a
valid address space qualifier.
Differential Revision: https://reviews.llvm.org/D59874
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357162
91177308-0d34-0410-b5e6-
96231b3b80d8
case tok::kw___kindof:
- case tok::kw_private:
case tok::kw___private:
case tok::kw___local:
case tok::kw___global:
case tok::kw___read_only:
case tok::kw___read_write:
case tok::kw___write_only:
-
return true;
+ case tok::kw_private:
+ return getLangOpts().OpenCL;
+
// C11 _Atomic
case tok::kw__Atomic:
return true;
case tok::kw___kindof:
- case tok::kw_private:
case tok::kw___private:
case tok::kw___local:
case tok::kw___global:
#include "clang/Basic/OpenCLImageTypes.def"
return true;
+
+ case tok::kw_private:
+ return getLangOpts().OpenCL;
}
}
// OpenCL qualifiers:
case tok::kw_private:
+ if (!getLangOpts().OpenCL)
+ goto DoneWithTypeQuals;
+ LLVM_FALLTHROUGH;
case tok::kw___private:
case tok::kw___global:
case tok::kw___local:
// cv-qualifier
case tok::kw_const:
case tok::kw_volatile:
+ return TPResult::True;
+
// OpenCL address space qualifiers
case tok::kw_private:
+ if (!getLangOpts().OpenCL)
+ return TPResult::False;
+ LLVM_FALLTHROUGH;
case tok::kw___private:
case tok::kw___local:
case tok::kw___global:
--- /dev/null
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+
+// Test that 'private' is not parsed as an address space qualifier
+// in regular C++ mode.
+
+struct B {
+ virtual ~B() // expected-error{{expected ';' at end of declaration list}}
+private:
+ void foo();
+ private int* i; // expected-error{{expected ':'}}
+};
+
+void bar(private int*); //expected-error{{variable has incomplete type 'void'}} expected-error{{expected expression}}