diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-07-27 20:30:05 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-07-27 20:30:05 +0000 |
commit | 020972d5d6dc1f3c49839cfbadcccf4cbefb2f4d (patch) | |
tree | 9d2878941fb01dbe00e2503a81e622d5c2114b7e | |
parent | 29e3ef8df84da298e7553a84276af4909ff6e9eb (diff) |
Forbid address-space-qualified function types, per TR 18037
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136257 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 8 | ||||
-rw-r--r-- | test/Sema/address_spaces.c | 4 |
3 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 25d7763be5..239bd45d22 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1195,6 +1195,8 @@ def err_attribute_address_space_too_high : Error< "address space is larger than the maximum supported (%0)">; def err_attribute_address_multiple_qualifiers : Error< "multiple address spaces specified for type">; +def err_attribute_address_function_type : Error< + "function type may not be qualified with an address space">; def err_as_qualified_auto_decl : Error< "automatic variable qualified with an address space">; def err_arg_with_address_space : Error< diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index e44c6c8b41..2f93642d2f 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -3072,6 +3072,14 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type, return; } + // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "A function type shall not be + // qualified by an address-space qualifier." + if (Type->isFunctionType()) { + S.Diag(Attr.getLoc(), diag::err_attribute_address_function_type); + Attr.setInvalid(); + return; + } + // Check the attribute arguments. if (Attr.getNumArgs() != 1) { S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1; diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c index a53bb4da00..24799daa9e 100644 --- a/test/Sema/address_spaces.c +++ b/test/Sema/address_spaces.c @@ -44,3 +44,7 @@ void test3(void) { extern void test3_helper(char *p); // expected-note {{passing argument to parameter 'p' here}} test3_helper(test3_array); // expected-error {{changes address space of pointer}} } + +typedef void ft(void); +_AS1 ft qf; // expected-error {{function type may not be qualified with an address space}} +typedef _AS1 ft qft; // expected-error {{function type may not be qualified with an address space}} |