]> granicus.if.org Git - clang/commitdiff
Add check for kind of UnqualifiedId in Declarator::isStaticMember()
authorPetar Jovanovic <petar.jovanovic@imgtec.com>
Mon, 30 Mar 2015 00:43:56 +0000 (00:43 +0000)
committerPetar Jovanovic <petar.jovanovic@imgtec.com>
Mon, 30 Mar 2015 00:43:56 +0000 (00:43 +0000)
Method CXXMethodDecl::isStaticOverloadedOperator expects Operator field
from the struct OperatorFunctionId, which is a member of the union in
the class UnqualifiedId. If the kind of UnqualifiedId is not checked,
there is no guarantee that the value that this method receives will be
correct, because it can be the value of another union member and not
OperatorFunctionId.

This bug manifests itself when running make check-all on mips64 BE.

This fix resolves the following regression tests:
Clang :: CXX/special/class.dtor/p9.cpp
Clang :: CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp
Clang :: CodeGenCXX/ctor-dtor-alias.cpp
Clang :: CodeGenCXX/debug-info-windows-dtor.cpp
Clang :: CodeGenCXX/dllexport-members.cpp
Clang :: CodeGenCXX/dllexport.cpp

Patch by Violeta Vukobrat.

Differential Revision:  http://reviews.llvm.org/D8437

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233508 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/DeclSpec.cpp

index f6689a96bdc3887a79bc22d2184b36ccbd46d10f..1e7fc750a9cf2bad803c5c4f72929a4b1a168272 100644 (file)
@@ -345,8 +345,9 @@ bool Declarator::isDeclarationOfFunction() const {
 bool Declarator::isStaticMember() {
   assert(getContext() == MemberContext);
   return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
-         CXXMethodDecl::isStaticOverloadedOperator(
-             getName().OperatorFunctionId.Operator);
+         (getName().Kind == UnqualifiedId::IK_OperatorFunctionId &&
+          CXXMethodDecl::isStaticOverloadedOperator(
+              getName().OperatorFunctionId.Operator));
 }
 
 bool DeclSpec::hasTagDefinition() const {