[PATCH] Sema: Don't assume a nested name specifier holds a type

Richard Smith richard at metafoo.co.uk
Sun Aug 4 17:35:57 PDT 2013


LGTM

On 4 Aug 2013 00:31, "David Majnemer" <david.majnemer at gmail.com> wrote:
>
> Sema::PerformObjectMemberConversion assumed that the Qualifier it was
> given holds a type.  However, the specifier could hold just a namespace.
> In this case, we should ignore the qualifier and not attempt to cast to
> it.
>
> http://llvm-reviews.chandlerc.com/D1283
>
> Files:
>   lib/Sema/SemaExpr.cpp
>   test/SemaCXX/PR16709.cpp
>
> Index: lib/Sema/SemaExpr.cpp
> ===================================================================
> --- lib/Sema/SemaExpr.cpp
> +++ lib/Sema/SemaExpr.cpp
> @@ -2311,7 +2311,7 @@
>    //     x = 17; // error: ambiguous base subobjects
>    //     Derived1::x = 17; // okay, pick the Base subobject of Derived1
>    //   }
> -  if (Qualifier) {
> +  if (Qualifier && Qualifier->getAsType()) {
>      QualType QType = QualType(Qualifier->getAsType(), 0);
>      assert(!QType.isNull() && "lookup done with dependent qualifier?");

This assert looks trivially impossible now. Remove?

>      assert(QType->isRecordType() && "lookup done with non-record type");
> Index: test/SemaCXX/PR16709.cpp
> ===================================================================
> --- /dev/null
> +++ test/SemaCXX/PR16709.cpp

Please fold this into an existing test file.

> @@ -0,0 +1,13 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
> +
> +namespace Foo {
> +struct Base {
> +  void Bar() {} // expected-note{{'Bar' declared here}}
> +};
> +}
> +
> +struct Derived : public Foo::Base {
> +  void test() {
> +    Foo::Bar(); // expected-error{{no member named 'Bar' in namespace
'Foo'; did you mean simply 'Bar'?}}
> +  }
> +};
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130804/b41ba73f/attachment.html>


More information about the cfe-commits mailing list