r199663 - Making some minor improvements to r199626.

Hal Finkel hfinkel at anl.gov
Fri Jul 11 07:48:04 PDT 2014


----- Original Message -----
> From: "Aaron Ballman" <aaron at aaronballman.com>
> To: cfe-commits at cs.uiuc.edu
> Sent: Monday, January 20, 2014 8:19:44 AM
> Subject: r199663 - Making some minor improvements to r199626.
> 
> Author: aaronballman
> Date: Mon Jan 20 08:19:44 2014
> New Revision: 199663
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=199663&view=rev
> Log:
> Making some minor improvements to r199626.
> 
> Modified:
>     cfe/trunk/include/clang/Basic/Attr.td
>     cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>     cfe/trunk/test/Sema/nonnull.c
> 

[snip]

> Modified: cfe/trunk/test/Sema/nonnull.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/nonnull.c?rev=199663&r1=199662&r2=199663&view=diff
> ==============================================================================
> --- cfe/trunk/test/Sema/nonnull.c (original)
> +++ cfe/trunk/test/Sema/nonnull.c Mon Jan 20 08:19:44 2014
> @@ -32,10 +32,10 @@ void test_baz() {
>    baz3(0); // no-warning
>  }
>  
> -void test_void_returns_nonnull() __attribute__((returns_nonnull));
> // expected-warning {{'returns_nonnull' attribute only applies to
> return values that are pointers}}
> -int test_int_returns_nonnull() __attribute__((returns_nonnull)); //
> expected-warning {{'returns_nonnull' attribute only applies to
> return values that are pointers}}
> -void *test_ptr_returns_nonnull() __attribute__((returns_nonnull));
> // no-warning
> +void test_void_returns_nonnull(void)
> __attribute__((returns_nonnull)); // expected-warning
> {{'returns_nonnull' attribute only applies to return values that are
> pointers}}
> +int test_int_returns_nonnull(void) __attribute__((returns_nonnull));
> // expected-warning {{'returns_nonnull' attribute only applies to
> return values that are pointers}}
> +void *test_ptr_returns_nonnull(void)
> __attribute__((returns_nonnull)); // no-warning
>  
>  int i __attribute__((nonnull)); // expected-warning {{'nonnull'
>  attribute only applies to functions, methods, and parameters}}
>  int j __attribute__((returns_nonnull)); // expected-warning
>  {{'returns_nonnull' attribute only applies to functions and
>  methods}}
> -
> +void *test_no_fn_proto() __attribute__((returns_nonnull));  //
> expected-warning {{'returns_nonnull' attribute only applies to
> functions and methods}}

This last check seems wrong to me. There is now a difference between this:

void *test_ptr_returns_nonnull(void) __attribute__((returns_nonnull));

which we handle and this:

void *test_ptr_returns_nonnull() __attribute__((returns_nonnull));

for which we ignore the attribute. However:

 - Most people don't put void in the parameter lists, and
 - gcc 4.9.0 does not distinguish between the two forms w.r.t. the application of this attribute.

Can you please fix this?

Thanks again,
Hal

> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the cfe-commits mailing list