r248928 - Don't correct non-class using declarations to class members.

2015-09-30 Thread Kaelyn Takata via cfe-commits
Author: rikka
Date: Wed Sep 30 13:23:35 2015
New Revision: 248928

URL: http://llvm.org/viewvc/llvm-project?rev=248928&view=rev
Log:
Don't correct non-class using declarations to class members.

Such declarations would be invalid anyway, and trying to make the
correction will lead to a crash. Fixes PR 24781.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/typo-correction.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=248928&r1=248927&r2=248928&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Sep 30 13:23:35 2015
@@ -8031,6 +8031,10 @@ public:
 
 // FIXME: Check that the base class member is accessible?
   }
+} else {
+  auto *FoundRecord = dyn_cast(ND);
+  if (FoundRecord && FoundRecord->isInjectedClassName())
+return false;
 }
 
 if (isa(ND))

Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=248928&r1=248927&r2=248928&view=diff
==
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Wed Sep 30 13:23:35 2015
@@ -640,3 +640,19 @@ int has_include(int); // expected-note {
 // expected-error@+1 {{__has_include must be used within a preprocessing 
directive}}
 int foo = __has_include(42); // expected-error {{use of undeclared identifier 
'__has_include'; did you mean 'has_include'?}}
 }
+
+namespace PR24781_using_crash {
+namespace A {
+namespace B {
+class Foofoo {};  // expected-note {{'A::B::Foofoo' declared here}}
+}
+}
+
+namespace C {
+namespace D {
+class Bar : public A::B::Foofoo {};
+}
+}
+
+using C::D::Foofoo;  // expected-error {{no member named 'Foofoo' in namespace 
'PR24781_using_crash::C::D'; did you mean 'A::B::Foofoo'?}}
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249090 - Don't try to get a CXXRecordDecl from a non-class TemplateSpecializationType.

2015-10-01 Thread Kaelyn Takata via cfe-commits
Author: rikka
Date: Thu Oct  1 17:38:51 2015
New Revision: 249090

URL: http://llvm.org/viewvc/llvm-project?rev=249090&view=rev
Log:
Don't try to get a CXXRecordDecl from a non-class TemplateSpecializationType.

With -fms-extensions it is possible to have a non-class record that is a
template specialization cause an assertion failure via the call to
Type::getAsCXXRecordDecl. Fixes PR 24246.

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=249090&r1=249089&r2=249090&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Oct  1 17:38:51 2015
@@ -3818,6 +3818,8 @@ void TypoCorrectionConsumer::addNamespac
   SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization;
   }
   for (const auto *TI : SemaRef.getASTContext().types()) {
+if (!TI->isClassType() && isa(TI))
+  continue;
 if (CXXRecordDecl *CD = TI->getAsCXXRecordDecl()) {
   CD = CD->getCanonicalDecl();
   if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=249090&r1=249089&r2=249090&view=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Thu Oct  1 17:38:51 2015
@@ -412,3 +412,13 @@ void AfterClassBody() {
   _Static_assert(__alignof(s1) == 8, "");
   _Static_assert(__alignof(s2) == 4, "");
 }
+
+namespace PR24246 {
+template  struct A {
+  template  struct largest_type_select;
+  // expected-warning@+1 {{explicit specialization of 'largest_type_select' 
within class scope is a Microsoft extension}}
+  template <> struct largest_type_select {
+blah x;  // expected-error {{unknown type name 'blah'}}
+  };
+};
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits